0

I'm trying to redirect all wildcard sub-domains to example.com via ISAPI Rewrite 2.

e.g. qqqq.example.com 301 redirects to example.com

Using other info here on Stack I've got the following to redirect www to non-www:

RewriteEngine on
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

Any help would be greatly appreciated as to what other Cond/Rules are needed.

Cheers

2 Answers2

0

The v2 syntax should be a little different:

RewriteCond Host: (?!www\.)[^.]+\.[^.]+\.[^.]+
RewriteRule (.*) http\://www.example.com$1 [RP]
TonyCool
  • 1,004
  • 1
  • 6
  • 5
  • Would this be added in addition to the above OP, or will these rules make sure the www is 301'd to the non-www also? – user1926349 Dec 27 '12 at 10:39
0

For ISAPI_Rewrite 2 you have to use a different syntax:

RewriteCond %HTTPS (on)?|.*
RewriteCond Host: (?!www\.)(.+)
RewriteRule (.*) http(?1s:)\://www.$2$3 [I,RP]
Lexey
  • 1
  • Thanks for your reply, but wouldn't this just redirect non-www to www? Rather than the wildcard sub-domains as well? – user1926349 Jan 02 '13 at 14:56