|
 |
|
สอบถามเกี่ยวกับ Mod rewrite ทีค่ะ จนปัญญาจริง ๆ ขอพี่ ๆ เทพทั้งหลายช่วยทีนะคะ หมดแรงแล้ว |
|
 |
|
|
 |
 |
|
http://www.generateit.net/mod-rewrite/
example:
Options +FollowSymLinks
RewriteEngine on
RewriteRule showproducts/(.*)/(.*)/$ /products/showproducts.php?$1=$2
คุณจะได้ url คือ http://www.domain.com/showproducts/ID/1/
|
 |
 |
 |
 |
Date :
2011-10-06 17:30:04 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแบบนี้ดูครับ เผื่อจะเข้าใจมากขึ้น
ไฟล์ทีี่ต้องใช้ 2 ไฟล์ คือ
1. ไฟล์สกุล .htacces ซึ่งใน host ที่เราเช่ามีการสร้างไว้ให้อยู่แล้ว copy มาลองใน appserv ได้เลย
2.ไฟล์ showproducts.php
2 ไฟล์ ด้านบนเอาไว้ folder เดียวกันครับ ในตัวอย่างผมไว้ที่ folder ชื่อ test
ขั้นตอน
1.ในไฟล์ .htacces เขียนคำสั่งตามด้านล่างนี้แล้ว Save
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^products/(.*).html showproducts.php?id=$1
</IfModule>
2.ในไฟล์ showproducts.php เขียนคำสั่งดังนี้
<?
echo $_GET['id'];
?>
ลองเปิด URL http://localhost/test/products/1.html
จากนั้นจะได้ค่า GET คือ 1 เราจะเอาค่านี้ไปใช้งานในเงื่อนไข อะไรต่อก็ได้เลยครับ
สำคัญที่การเขียน Regular Expression ของเราให้ match ครับ
(จะงงเปล่านี่)
|
 |
 |
 |
 |
Date :
2011-10-06 17:58:56 |
By :
อดีตเคย งง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แงๆๆๆๆๆๆๆๆๆๆๆ ไม่เข้าใจจริง ๆ ค่ะ
มึนตึ๊บบ
พี่คะพอมีใครว่าง add msn มาหาหนูได้มั้ยคะ
[email protected]
ปวดจิตจริง ๆค่ะ
|
 |
 |
 |
 |
Date :
2011-10-06 18:47:25 |
By :
thaimaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|