Phil Jackson
Phil Jackson

Reputation: 10288

Htaccess rewrites for subdomains

I have been trying to put 2 seperate sites in subfoldres and use rewites to load them.

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.udstde\.co\.uk
RewriteCond %{HTTP_HOST} test1\.udstde\.co\.uk
RewriteRule (.*) /test1/index.php [L]

RewriteCond %{HTTP_HOST} !^www\.udstde\.co\.uk
RewriteCond %{HTTP_HOST} test2\.udstde\.co\.uk
RewriteRule (.*) /test2/index.php [L]

The problem being the first one works fine but the second one doesn't.

Can anyone see where im going wrong?

Upvotes: 1

Views: 57

Answers (2)

Ravi Bhatt
Ravi Bhatt

Reputation: 3163

I see the problem, in your first set of conditions,

RewriteCond %{HTTP_HOST} !^www\.udstde\.co\.uk
RewriteCond %{HTTP_HOST} test1\.udstde\.co\.uk

whenever test2 comes up, above condition turns true as both conditions turn false. (i guess)

Upvotes: 1

Phil Jackson
Phil Jackson

Reputation: 10288

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.udstde\.co\.uk
RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).udstde\.co\.uk [NC]
RewriteRule (.*) %1/$1 [L]

Upvotes: 0

Related Questions