Matti Matti - 4 months ago 59
Apache Configuration Question

.htaccess subdomains to _GET

I'm trying to use .htaccess rewriting to redirect subdomains to PHP variables.

I'd like it to work like this:

User enters:

Page redirects to:

But the user doesn't see the URL change.

Kind of like how this works but with the subdomains:

RewriteEngine on
RewriteRule ^(.*)$ index.php?page=$1 [NC,QSA]

This is my first time using stackoverflow, thanks for the help in advance!


You can use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$  [NC]
RewriteRule ^(.*)$ index.php?sub=%1&page=$1 [QSA,L]