Menu
Mod Rewrite ใน Localhost

Mod Rewrite ใน Localhost

 คนทำเว็บ  2015-11-12 11:49:10  3,474

บทความ : Mod Rewrite ใน Localhost

หลายครั้งที่ต้องมีการทดสอบ Mod Rewrite บนเครื่อง Localhost แต่เนื่องจาก Path ไม่ตรงกับบน Server ที่ใช้งานจริง วันนี้เรามาเรียนรู้การกำหนด File .httaccess เพื่อให้สามารถใช้งาน บน Localhost ของเราได้ครับ

1. ทดสอบว่า locahost ของเราสามารถรัน mod rewrite ได้แล้ว

2. สร้าง .htaccess โดยใส่ข้อมูลด้านล่างนี้


AddDefaultCharset utf-8

Options +FollowSymLinks
Options +Indexes
Options -Multiviews

#SAMPLE
#RewriteRule ^content/([^/]*)\.htm$ /my_php/my_website_folder/content_view.php?id=$1 [L] 

RewriteRule ^content/([^/]*)\.htm$ /PATH_FOLDER_WEBSITE/content_view.php?id=$1 [L]

RewriteEngine On

3. ทดสอบ URL ต้องสามารถรันได้ 
จากตัวอย่างด้านบน http://localhost/content/id.htm

หากชอบบทความนี้ กดให้ค่ากาแฟที่นี่ครับ Support Me on Ko-fi

ฝากติดตามผลงานด้านล่างด้วยครับ

--------------------------
► Website : https://www.siamfocus.com/
► LINE@ : https://line.me/ti/p/@siamfocus.com
► Facebook : https://www.facebook.com/fanpage.siamfocus
► Twitter : https://twitter.com/siamfocus
► Instagram : https://www.instagram.com/iamtaam
--------------------------

รับทำเว็บไซต์ สอนทำเว็บไซต์ รับดูแลเว็บไซต์

สายด่วนโทร 061-583-7888

บทความแนะนำ