我已经重写了像
这样的htaccess的一部分RewriteRule ^articles/([^/]*)/([^/]*)/$ /index.php?section=articles&page=$1&id=$2 [L]
RewriteRule ^articles/([^/]*)/([^/]*)$ /index.php?section=articles&page=$1&id=$2 [L]
RewriteRule ^articles/([^/]*)/$ /index.php?section=articles&page=$1 [L]
RewriteRule ^articles/([^/]*)$ /index.php?section=articles&page=$1 [L]
RewriteRule ^articles/$ /index.php?section=articles [L]
RewriteRule ^articles$ /index.php?section=articles [L]
但是当我编写例如/articles/detail/1
时,它可以正常工作,但是当我在末尾添加反斜杠(/articles/detail/1/
)时,却没有。
感谢您的帮助。
答案 0 :(得分:1)
实际上问题确实是在你的规则中放置了斜杠。 所有规则中的尾随斜杠都应该是可选的,如下所示:
RewriteRule ^articles/([^/]+)/([^/]+)/?$ /index.php?section=articles&page=$1&id=$2 [L]
RewriteRule ^articles/([^/]+)/?$ /index.php?section=articles&page=$1 [L]
RewriteRule ^articles/?$ /index.php?section=articles [L]