0

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.

MagicalArmchair
  • 265
  • 3
  • 10

2 Answers2

1

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]
MagicalArmchair
  • 265
  • 3
  • 10
0

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]
Andrew
  • 116
  • 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