รบกวนแนะนำการทำ short link ด้วย mod_rewrite หน่อยครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา รบกวนแนะนำการทำ short link ด้วย mod_rewrite หน่อยครับ
รบกวนแนะนำการทำ short link ด้วย mod_rewrite หน่อยครับ
อยากเปลี่ยนลิงค์จาก
http://www.mysite.com/content.php?arti_name=article_name
เป็น http://www.mysite.com/content/article_name.html ครับ
ตอนนี้เขียน mod_rewrite แบบนี้ครับ
RewriteEngine On
RewriteBase /content/
RewriteRule ^(.*).html content.php?arti_name=$1
ไม่ทราบว่าผิดตรงไหน รบกวนชี้แนะด้วยครับ ตอนนี้ ผลที่ออกมาดันไม่เจอหน้าอะไรเมื่อพิมพ์ http://www.mysite.com/content/article_name.html ครับ

คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
ความคิดเห็นที่
1
สร้างไฟล์ content.php ไว้ใน public_html
ใช้ mod_rewrite ใน .htaccess ประมาณนี้ดู
1 2 3 4 5 | RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http: //www.%{HTTP_HOST}/$1 [R=301,L] RewriteRule ^content/([^/]*).html$ /content.php?arti_name= $1 [L] |

ความคิดเห็นที่
2
ได้ล่ะครับ แล้วถ้าจะตรวจสอบหลายตัวแปร ลองทำดูแล้ว แต่ว่าตรวจสอบได้แต่ค่า /content.php?arti_topic=$1 ครับ ถูกผิดจุดไหนรบกวนแนะนำด้วยครับ
1 2 3 4 5 6 7 | RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http: //www.%{HTTP_HOST}/$1 [R=301,L] RewriteRule ^a=([^/]*)$ /content.php?arti_topic= $1 [L] RewriteRule ^n=([^/]*)$ /show_news.php?news_topic= $2 [L] RewriteRule ^p=([^/]*)$ /show_product.php?name_product= $3 [L] |

ขอบคุณทุกการสนับสนุน
![]()