【发布时间】:2015-10-25 04:58:24
【问题描述】:
寻找解决方案如何删除 URL 最后一个斜杠后面的任何内容。
示例输出网址:
http://example.com/pictures/123/category-name/
此网址要避免的问题:
http://example.com/pictures/123/category-name/blah.html
http://example.com/pictures/123/category-name/blah/blah.html
http://example.com/pictures/123/category-name/blah/blah/blah.html
http://example.com/pictures/123/category-name/blah/
http://example.com/pictures/123/category-name/blah
到目前为止,我有这个:
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/category-name/$ $1/$2/category-name/ [R]
RewriteRule ([A-Za-z0-9-]+)/([0-9]+)/category-name/(.*)$ category.php?VarA=$1&VarB=$2
它适用于输出 URL 和带有任何模式的 URL。问题是如果最后一个斜杠后面有任何内容,它不会重写(重定向)到输出 URL。
【问题讨论】:
标签: apache .htaccess url mod-rewrite