Reputation: 5779
We're currently using this rule:
RewriteRule ^testsub/ - [L]
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteRule ^(.*)$ testsub/$1 [L]
But, we're unable to to easily have more rules to rewrite subdomains to seperate folders.
Copying and pasting means all subdomains are going to testsub.website.com
If I add the following condition I can get around it:
RewriteCond %{HTTP_HOST} !^(test|alt)\.website\.com$ [NC]
But as you can see from below it's still a big, ugly rewrite... how can I easily make just 1 set of rules to do all of the below as like 4-5 lines max
RewriteRule ^testsub/ - [L]
RewriteCond %{HTTP_HOST} !^(test|alt)\.website\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteRule ^(.*)$ testsub/$1 [L]
RewriteRule ^test/ - [L]
RewriteCond %{HTTP_HOST} !^(testsub|alt)\.website\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteRule ^(.*)$ test/$1 [L]
RewriteRule ^alt/ - [L]
RewriteCond %{HTTP_HOST} !^(testsub|test)\.website\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteRule ^(.*)$ alt/$1 [L]
Upvotes: 1
Views: 36
Reputation: 469
You can use like this
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteRule ^(testsub|test|alt)(.*)$ $1/$2 [L]
I hope that helps!
Upvotes: 3