www.www.

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 21 Jul 2012, 20:15

www.www.

21 Jul 2012, 20:20

Hi

Used the "Redirecting non-www version to www" for our site from examples on our site, but have noticed that a few urls are starting to get indexed in google which are just plain strange.
http://www.www. etc..

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


Now I know we can do rel canonical on our pages, but really dont feel this should be needed.
Anything we can do to fix this?

We just want <domainname>.com to redirect to http://www. and leave it at that.

Anyone?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: www.www.

23 Jul 2012, 07:07

Well, this rule has been verified hundreds of times, so we can simply hardcode it a little for you:

Code: Select all
RewriteCond %{HTTP:Host} ^(yourDomain\.com)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http://www.%1%2 [NC,R=301,L]


But I don't think it's the rule, there could be other settings elsewhere that do the same.

Regards
Andrew

User avatar
Posts: 2
Joined: 21 Jul 2012, 20:15

Re: www.www.

23 Jul 2012, 07:56

Hi Andrew

And thanks for that.
After your comments about other settings I decided to try and completely remove all conditions and the result is the same.
Very very strange. Something somewhere is doing the redirection and only seems to happen when I use a masterpage.
Going to have to dig deeper.

Regards,
Soeren

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: www.www.

08 Mar 2013, 13:44

HeliconAndrew wrote:Well, this rule has been verified hundreds of times, so we can simply hardcode it a little for you:

Code: Select all
RewriteCond %{HTTP:Host} ^(yourDomain\.com)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http://www.%1%2 [NC,R=301,L]


But I don't think it's the rule, there could be other settings elsewhere that do the same.

Regards
Andrew


I have a site where they want to redirect the domain.co.uk to domain.com, as well as sweeping up the non-www variants.

I went to the Apache docs and it said to use a Redirect directive within VirtualHost tags, but ISAPI_Rewrite says it's invalid.

Is a variant of the above the way to achieve this?

The alternative (which seems a little kludgy) is to set up another website in IIS, point the .co.uk and non-www bindings to it and use a 301 redirect in IIS.

Thoughts?

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 10 guests