[Sussex] htaccess & 301s

Dominic Humphries linux at oneandoneis2.org
Wed Oct 21 17:55:25 UTC 2009


Evening all,

I've got an annoying problem with trying to set up a 301 redirect on a 
website.

It's a SEO thing, they want to avoid having 'www' in their URL. So that 
should be easy enough, you can set up a redirect to send all 
'www'-containing addresses to the non-www alternative.

Problem is, all the redirects seem to follow this format:

rewritecond %{http_host} ^www.domain.com [nc]
rewriterule ^(.*)$ http://domain.com/$1 [r=301,nc]

And this site needs to have some pages secure, i.e. accessed via httpS - 
and the above code always redirects to plain http.

Is there any way to set up a redirect so any attempt to access 
www.domain.com gets sent to domain.com, but everything else gets left 
alone? Or failing that, a way to stop it redirecting https requests?

Thanks in advance!

Dominic



More information about the Sussex mailing list