redirect non-www URL to www URL

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: redirect non-www URL to www URL

redirect non-www URL to www URL

by coquilla18 » 02/10/2014 5:55 pm

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]

Top