1

我已经重写了 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/,它却没有。

谢谢您的帮助。

4

1 回答 1

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]
于 2013-08-15T10:19:11.643 回答