Apache rewrite rule which works with or without a trailing slash

后端 未结 4 1767
南旧
南旧 2021-02-04 01:27

I\'m trying to redirect a series of static URLs, and I want it to work whether or not the trailing slash is present:

/foo/bar  --->  /tacos
/foo/bar/  -->          


        
4条回答
  •  旧时难觅i
    2021-02-04 02:08

    Other than in EBNF or ABNF, a quantifier in regular expressions refers the preceding expression and not the following expression.

    So:

    RewriteRule ^foo/bar/?$ http://url.com/tacos
    

提交回复
热议问题