Redirecting Webpage To WWW Prefix

Published May 24th 2009 by
Filed under HTML

When a domain is entered in a browser, it can be entered with or without the www prefix. For example, Let-Go.net can be reached from either let-go.net or www.let-go.net. Search engines will pick this up as 2 different webpages which will half your ranking on the search engines search results. There is a way to make make it a single webpage using a redirection. You must choose to either use the www prefix or not. To do this, make a new .htaccess file or edit an existing one in the root of where your site is hosted. In the .htaccess file, enter the following replacing the Let-Go.net url with your own:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.let-go\.net [NC]
RewriteRule ^(.*)$ http://www.let-go.net/$1 [L,R=301]
</IfModule>

Save the file and upload it. This will redirect your site to the www prefix when the prefix is not entered making it one webpage on search engines. To redirect it to exclude the www prefix, take out “www\.” and the “www.” in the code above.