Forum Moderators: phranque
myname.example.com
-to-
www.example.com:8080/pages/co.faces?var=myname
What I have so far in my .htaccess is this:
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]*)\.example.com$
RewriteRule .* http://www.example.com:8080/pages/co.faces?var=%1 [L]
Which is working fine, except that the user sees the new (and long and ugly) URL rather than staying on the original "myname.example.com" URL.
How do I keep the new URL from showing?
Which do you want?
Your code probably performs a 302 redirect as coded right now.
You could turn that into a 301 redirect by changing [L] into [R=301,L].
You could turn the existing code into a rewrite by omitting the domain name from the "right" of the rule.
How do the subdomains map to your filesystem anyway?
I removed the domain name from the beginning of the rewrite rule, but now all I get is an Internal Server Error.
The rule is now:
RewriteRule .* pages/co.faces?var=%1 [L]
(and also tried this one with the leading slash, which also doesn't work):
RewriteRule .* /pages/co.faces?var=%1 [L]
:(
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([a-z0-9][a-z0-9_\-]*[a-z0-9])\.example\.com
RewriteCond %{QUERY_STRING} !&?var=[^&]+
RewriteRule .* pages/co.faces?var=%1 [L]
Consider: How do you want to handle image requests? CSS and external JavaScript file requests? What about requests for favicon.ico, robots.txt, labels.rdf, sitemap.xml? These objects *will almost certainly* be requested from the subdomains, and you need a plan to handle them.
Jim