Using HTACCESS to Redirect Non-WWW URLs to WWW

Posted by Systems Cowboy on March 1, 2011

This is pretty basic but essential for good SEO.

If you have a site and the http://systemscowboy.com and http://www.systemscowboy.com both show up as separate URL’s, you need to redirect one to the other so you don’t have two separate URL’s displaying the exact same content.

Here’s how to use your .htaccess file to redirect non-www URL’s to www:

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

This will make it so somebody who types in http://systemscowboy.com will automatically be redirected to http://www.systemscowboy.com.

Add Your Comment