Redirect http:// to http://www via htaccess

Reading Time: < 1 minute

Add the below code to your htaccess file, replacing the domain name with yours.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.google\$
RewriteRule (.*)$1 [R=301,L]

One thought on “Redirect http:// to http://www via htaccess

  1. Good stuff this, we’ve just implemented this on our site to avoid having duplicate homepages in the index! Also to anyone reading, don’t forget you can specify in google webmaster tools if you want google to use the http:// or http://www. version of your site too.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.