Forum Moderators: phranque

Message Too Old, No Replies

Problems with virtual subdomains and variable

htaccess, problems with virtual subdomains and variable

         

almazan01

7:17 am on Jan 11, 2009 (gmt 0)

10+ Year Member



Hi, I create a dynamic subdomains like this, example:

[mywebsite.com...] to [texas.mywebsite.com...]
and show me all the articles related to the state of texas, its OK

the .htaccess code is:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mywebsite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.mywebsite.com
RewriteRule ^(.*)$ search.php?state=%1

So, everything is fine

but when I want navigate in these subdomain [texas.mywebsite.com...] (the article url is hhtp://www.mywebsite.com/article.php?title=cars%20in%20texas&id=5)

don’t show the article, show the same page [texas.mywebsite.com...] an the articles related whit texas.

as would show the article without leaving the subdomain
(http://www.texas.mywebsite.com/cars-in-texas-5.html)

g1smd

5:47 pm on Jan 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Escape both of the periods in both
RewriteCond
lines for starters.

End anchor the URL in the first

RewriteCond
.

Note that

^(.*)$
simplifies to
(.*)

The brackets aren't required if you aren't using that backreference.

Always avoid spaces and underscores in URLs. They always cause problems.