Page 1 of 1

redirect non-www URL to www URL

Posted: 02/10/2014 5:55 pm
by coquilla18
Modify .htaccess file

www to non-www redirect

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} www.yoursite.com
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
non-www to www redirect

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
Some Code could be use without specifying your domain name

Code: Select all

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