Htacess Rewrite Rule - Doesn't work without Trailing Slash

后端 未结 2 376
孤街浪徒
孤街浪徒 2021-01-25 16:59

So I have the following Rewrite Rules:

RewriteRule ^([a-z0-9_\\-]+)(\\.php)?$ index.php?page=$1 [NC,L,QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?shop=$1&         


        
相关标签:
2条回答
  • 2021-01-25 17:13

    In your second rule, add ? after trailing slash:

    RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?shop=$1&page=index [NC,L,QSA]
    

    That will make trailing / optional

    0 讨论(0)
  • 2021-01-25 17:29

    I usually end my rules with /?$ meaning string ending with one slash or no shash.

    0 讨论(0)
提交回复
热议问题