Matti Matti - 1 year ago 220
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!

Answer Source

You can use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$  [NC]
RewriteRule ^(.*)$ index.php?sub=%1&page=$1 [QSA,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download