我希望地址栏显示的内容:
http://facebook.com/user
http://facebook.com/user/ -> http://facebook.com/user
http://facebook.com/user/photos -> http://facebook.com/user/photos
我的重写规则:
RewriteEngine On
RewriteRule ^(.+)/$ $1 [NC]
RewriteRule ^([A-Za-z0-9_-]+)/?([A-Za-z0-9_-]*)$ user.php?id=$1&second=$2 [NC,L]
怎么了:
1). http://domain.com/user (working well)
2). http://domain.com/user/ (keeps the / in the address bar and destroys css/js/img paths)
3). http://domain.com/user/photos (same result as 2, correct except the paths)
如果我使用<base href="...">
强制路径页面正确显示。但我想在没有它的情况下解决我的问题。
如何删除地址栏中的尾部斜杠?重写似乎按预期工作。