Force a domain redirection with a .htaccess file

Posted on

Because of the RFC 6265 and for the SEO effort you should always redirect all your aliases to the www subdomain.

Else all the cookies created for the (without www) will be sent to all the subdomains (e.g.

Also you don’t have the possibility to set multiple servers (Round-robin) for your domain, as there can be only one A Record for the default domain.

The following little snippet should help you with that. Just replace with your domain and put it into your .htaccess file.

If it doesn’t work, check if you’ve activated the rewrite module of apache. If it still doesn’t work, please leave a comment with the related part of your logfile.

Leave a Reply