ส่วนบริการลูกค้า > คู่มือการใช้งาน > Webmaster Tips > การใช้ mod_rewrite เพื่อทำ url ภาษาไทย


การใช้ mod_rewrite เพื่อทำ url ภาษาไทย




เนื่องจาก url เป็นส่วนหนึ่งที่สำคัญต่อการทำ SEO มากๆ ในบางครั้งเมื่อเราต้องการทำ SEO keyword ภาษาไทย ซึ่งเราต้องใส่ ภาษาไทย ลงใน url หรือที่เรารู้จักกันในนาม url-friendly

สามารถทำได้ โดยการใช้ mod_rewrite เข้ามาช่วย สามารถทำได้ง่ายๆ ตามขั้นตอนข้างล่างนี้เลยครับ

1. สร้างไฟล์ .htaccess แล้วนำไปใส่ไว้ใน public_html

โดยใน .htaccess ไฟล์ให้ใส่ข้อความดังนี้

 

Options +FollowSymLinks

 

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ url-friendly.php?url=$1 [L]

 

2. ให้สร้างไฟล์ url-friendly.php ขึ้นมาและใส่ข้อความดังนี้

 

if(!empty($_GET['url']))

include(iconv(‘UTF-8′, ‘TIS-620′, $_GET['url']));

?>

 

3. ลอง upload ไฟล์ ภาษาไทย.html ขึ้นไปบน server แล้วเรียกดู



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Landing Page Optimization (คนดู: 126)
PPC Consulting Service (คนดู: 116)

Powered by WHMCompleteSolution

เปลี่ยนภาษา:
Back to Top

Follow us on Twitter, Facebook or Google+ to receive updates regarding network issues, discounts and more.
2013 © CMSHostThailand.com - All rights reserved.

ads