301 Redirect www with Htaccess

301 Redirect Non-WWW to WWW URL’s with Htaccess

It is important to decide on a consistent URL formatting from the beginning of your site.

Place this at the top of your htaccess file. BE SURE TO REPLACE EXAMPLE.COM WITH YOUR DOMAIN ON LINE 2 & 3:

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

301 Redirect WWW to Non-WWW URL’s with Htaccess

It is important to decide on a consistent URL formatting from the beginning of your site.

Place this at the top of your htaccess file. BE SURE TO REPLACE EXAMPLE.COM WITH YOUR DOMAIN ON LINE 2 & 3:

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

NOTES…
* Htaccess redirects works only with linux and unix servers (not IIS)
* After completing redirect check at least two pages (homepage and sub-page) with our server header tool – Look for 301 redirect