Query string parameter after subdomain


This Content is from Stack Overflow. Question asked by Eleanor Gotell

I’m trying to assign the parameter for subdomain to a variable but seems it isn’t working
Its actually working for my main domain but not the subdomain. Anyone can assist me with this?
[main domain] -> example.com/parameter, [subdomain] -> sub.example.com/parameter

In my htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^(.*)$ $1.php [L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

And in my index.php file

$queryvar = $_SERVER['QUERY_STRING'];
echo $queryvar;


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?