redirect non-www URL to www URL

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: redirect non-www URL to www URL

redirect non-www URL to www URL

โดย coquilla18 » 02/10/2014 5:55 pm

Modify .htaccess file

www to non-www redirect

โค้ด: เลือกทั้งหมด

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

โค้ด: เลือกทั้งหมด

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

โค้ด: เลือกทั้งหมด

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

ข้างบน