http://foo.domain.com/bar
redirects without changing the browser to:
http://www.domain.com/foo.php?this=bar
and
http://foo.domain.com/bar/whee.html
redirects without changing the browser to:
http://www.domain.com/foo.php?this=bar&other=whee
I have wildcard subdomains set up and I almost have it with the following setup. It just doesn't catch the specific subdomain and translate it to that "subdomain.php" script:
- Code: Select all
RewriteEngine On
RewriteRule ^$ /foo.php [QSA,L]
RewriteRule ^([^/\.]+)$ /foo.php?this=$1 [QSA,L]
RewriteRule ^([^/\.]+)/([^/\.]+)\.html$ /foo.php?this=$1&other=$2 [QSA,L]
But that only works because every subdomain is going to the foo.php script. So "http://narf.domain.com/bar/whee.html" is also going to "http://www.domain.com/foo.php?this=bar&other=whee" when I actually will want that going to "http://www.domain.com/narf.php?thisothervar=bar&somethingelse=whee"
And, of course, I want "www." to just go to the main index.php page.
So, can specific subdomains be used to catch the url? Something like:
Rewrite Cond (If foo.domain.com)
RewriteRule ^([^/\.]+)$ /foo.php?this=$1 [QSA,L]
RewriteRule ^([^/\.]+)/([^/\.]+)\.html$ /foo.php?this=$1&other=$2 [QSA,L]
Rewrite Cond (if narf.domain.com)
RewriteRule ^([^/\.]+)$ /narf.php?this=$1 [QSA,L]
RewriteRule ^([^/\.]+)/([^/\.]+)\.html$ /narf.php?thisothervar=$1&somethingelse=$2 [QSA,L]
Then deal with anything else?
Many thanks for pointing me in the right direction.
Edit: Changed subject to clarify I'm talking about "specific" subdomains and not just catching "any" subdomain.