domain.com to www.domain.com redirection

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 23
Joined: 10 Oct 2012, 16:22

domain.com to www.domain.com redirection

12 Oct 2012, 08:43

Hello,

I have eventually got Helicon Ape working within a Win2008R2 x64 / WSP environment, however I am having one particular issue.

The redirection from domain.com to http://www.domain.com is not working. I might just revert back to IIS Rewrite for this job, however before I start changing everything I wanted to know if the following code should work:

Code: Select all
RewriteRule ^(.*) http://www\.domain\.com/$1 [R=301,L]


I understand that this should do that job, however it causes a redirect loop when trying to use 'www.domain.com'.

Any help would be greatly appreciated

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

Re: domain.com to www.domain.com redirection

12 Oct 2012, 10:23

The classic rule from our examples page would be:

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


you may simplify that to:

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


Regards
Andrew

User avatar
Posts: 23
Joined: 10 Oct 2012, 16:22

Re: domain.com to www.domain.com redirection

12 Oct 2012, 11:29

Thanks Andrew. That has worked perfectly :D

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 22 guests