This small tutorial will show you how to force the use of “www” in you URL.

How many sites link to your site without the “www”? Consolidate you page rank and links by forcing the use of one host name.

You will need Apache and mod_rewrite for this to function properly. Create an .htaccess file and place the following commands in it. If you already have an .htaccess file then simply update it.

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

You will need to obviously change “” to your own domain.

The status code of the redirection is 301 Moved Permanently. A 301 redirect is the safest redirect because it helps preserve search engine ranking and page rank. Redirection should be setup properly on you web site now.

mod_rewrite is an Apache module which uses a rule-based rewriting engine, based on regular expression, to manipulate requested URLs on the fly.


Google now has a feature for you to set the preferred domain in Google webmaster tools.