0

We are using a wildcard subdomain, *.subdomain.com Each state has its own directory inside the /state/ directory, and within that directory there is a state.html. The URL would be domain.com/state/$state/state.html which would then be rewritten to show domain.com/state.html?state=$state

All works good but now we need to go from subfolder to subdomain so the ending result would be either

$state.domain.com - Preferred but not necessary or $state.domain.com/state.html?state=$state

What we have currently is below, but we get a redirect loop.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain.com
RewriteCond %{HTTP_HOST} ^(.+).domain.com
RewriteRule ^([^/]*)$ /state/%1 [P,L,QSA]

#Rewrite Rule - Force state and city lookup to use state.html or city.html and use info from url to define which city and state.
RewriteRule ^state/(.*)$ state.html?state=$1 [L]
RewriteRule ^city/(.*)/(.*)$ city.html?city=$1&state=$2 [L]

1 Answer 1

0

Ended up using the following which works

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain.com
RewriteCond %{HTTP_HOST} ^(.+).domain.com
RewriteRule ^([^/]*)$ /state/%1/state.html?state=$1 [L,QSA]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.