Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my httpd.ini I redirect all traffic from "example.co.uk" to "www.example.co.uk", the below works fine for this:

RewriteCond %HTTPS off 
RewriteCond Host: (?!^www.example.co.uk)(.+) 
RewriteRule /(.*) http\://www.example.co.uk/$2 [I,RP]

I have a bunch of microsites which also use this website, say "www.foobar.co.uk", set in the Host Headers of IIS 6. With the above rules, "www.foobar.co.uk" ends up at "www.example.co.uk"!

Is there a RewriteCond I can do against the request to make sure that the request is for "example.co.uk" to not capture the microsites and rewrite those? Or even better, a way I can take any request, be it "example.co.uk" or "foobar.co.uk" and just wack a www in front of it?

Thanks for your help.

share|improve this question

2 Answers 2

I made this work with multiple URLs (and Andrews help), with the below.

RewriteCond %HTTPS off 
RewriteCond Host: (?!^www.+)(.+) 
RewriteRule /(.*) http\://www.$1/$2 [I,RP]
share|improve this answer

Try using the following:

RewriteCond %HTTPS off 
RewriteCond Host: !^www\..+ 
RewriteCond Host: ^(example|foobar)\.co\.uk
RewriteRule /(.*) http\://www.$1.co.uk/$2 [I,RP]
share|improve this answer
    
Unfortunately, this doesn't work "example.co.uk" and "foobar.co.uk" stay as such, no www. on the front. It no longer breaks www.foobar.co.uk anymore though, but then it doesn't do anything else either :(. –  MagicalArmchair Jun 14 '12 at 14:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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