[英]Htaccess mod_rewrite - slash
I have rewrite part of htaccess like 我已经重写了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]
But when I write for example /articles/detail/1
it works properly, but when I add backslash into the end ( /articles/detail/1/
), it doesn't. 但是,当我编写例如
/articles/detail/1
它可以正常工作,但是当我在末尾添加反斜杠( /articles/detail/1/
)时,它就不行了。
Thank you for your help. 谢谢您的帮助。
Actually problem is indeed placement of trailing slash in your rule. 实际上,问题确实在于规则中是否放置了斜杠。 Trailing slash should be made optional in all the rules like this:
在所有此类规则中,尾部斜杠应设为可选 :
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.