Tuesday, February 21, 2012

Redirect non-www URLs to www URLs using a .htaccess file

Create a notepad file and save it as .htaccess if you do not already have an existing one.

Update the .htaccess file with the following code and save; be sure to replace domain.com with your domain name.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain.com [NC]

RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Upload the .htaccess file via ftp to the site root and now your traffic will be redirected to www.domain.com.

0 comments:

Post a Comment