簡體   English   中英

htaccess mod_rewrite-斜杠

[英]Htaccess mod_rewrite - slash

我已經重寫了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/ )時,它就不行了。

謝謝您的幫助。

實際上,問題確實在於規則中是否放置了斜杠。 在所有此類規則中,尾部斜杠應設為可選

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM