我是 URL 重写的新手,所以我刚刚掌握它的窍门。我遇到的问题是我的规则有效并提取了正确的页面,但在页面加载后,它显示重写的 URL,而不是地址栏中的尾部斜杠。
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)/(.+)/([0-9]+)$ ^testing.php?do=$1&see=$2&id=$3 [NC,L]
所以不要看到 http://www.example.com/walk/cars/9843928在地址栏中,我看到 http://www.example.com/testing.php?do=walk&see=cars&id=9843928
我可以让它正常工作并将尾部斜杠 URL 保留在栏中吗?
最佳答案
目标网址不应以 ^
开头。
将您的代码替换为:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/?$ testing.php?do=$1&see=$2&id=$3 [L,QSA]
关于php - mod_rewrite 显示重写的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18913905/