Redirect www to domain (.htaccess) / การส่งต่อ www ไปยังโดเมนด้วย .htaccess

Hint: Instead of creating your own .htaccess file, simply use the home page settings in the control panel to choose where we should redirect everyone for you!


If you want your website to run on the naked domain, for example example.co.th instead of www.example.co.th you can remove these rules, or change so that www is forwarded to the naked domain.

If you want to use these rules on an older package, you can add this to your .htaccess file (replace YOUR-DOMAIN.COM with your own domain name, small letters)

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond% {HTTP_HOST}! ^ www.YOUR-DOMAIN.COM [NC]
 RewriteRule ^ (. *): //www.YOUR-DOMAIN.COM/$1 [L, R = 301]
</IfModule>
	

Additional explanation:

The naked domain is your domain without a prefix, so for example: "example.co.th".

Subdomains are the prefixes for your domain, for example "www" or "test". The subdomain "www" is a bit special, because it is very common to use "www"

สำหรับภาษาไทยดังนี้

หากท่านต้องการให้เว็บไซต์ของท่านสามารถเข้าใช้งานได้ด้วย naked domain เช่น example.co.th แทนการเข้าด้วย www.example.co.th สามารถทำได้โดยการส่งต่อ www ไปยัง naked domain นั่นก็คือ example.co.th

หากต้องการใช้งานส่วนนี้ในแพ็คเกจโดเมนแบบเก่า ท่านสามารถเพิ่มในไฟล์ .htaccess ( แทน JEDOMEIN.COM ด้วยชื่อโดเมนของท่าน )

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond% {HTTP_HOST}! ^ www.YOUR-DOMAIN.COM [NC]
 RewriteRule ^ (. *): //www.YOUR-DOMAIN.COM/$1 [L, R = 301]
</IfModule>
	

คำอธิบายเพิ่มเติม

Naked domain คือโดเมนที่ไม่มีคำนำหน้าเช่น example.co.th

ซับโดเมน คือ คำนำหน้าของโดเมน เช่น www หรือ test ซับโดเมน www คือ คำนำหน้าเฉพาะ เพราะการใช้คำนำหน้าชื่อโดเมนด้วย www เป็นเรื่องปกติของโดเมนทั่วไป

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.