[Sussex] htaccess & 301s

John Crowhurst info at johnscomputersupport.co.uk
Thu Oct 22 07:16:42 UTC 2009


On Wed, October 21, 2009 18:55, Dominic Humphries wrote:
> 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]

Why not simply change the rewrite rule to:

rewriterule ^(.*)$ https://domain.com/$1 [r=301,nc]

If you have access to the server config, the redirect may work for you:

<VirtualHost *:80>
Redirect permanent / http://domain.com/
ServerName www.domain.com
</VirtualHost>

<VirtualHost *:443>
Redirect permanent / https://domain.com/
ServerName www.domain.com
</VirtualHost>

-- 
John Crowhurst
John's Computer Support



More information about the Sussex mailing list