mod_rewrite with trailing period in URL

前端 未结 2 635
广开言路
广开言路 2021-01-07 13:59

I have a RewriteRule on my Apache to make URLs friendly

RewriteRule ^log/(.+)$ script.php?u=$1 [QSA] 

This makes http://example.com/log/use

2条回答
  •  旧时难觅i
    2021-01-07 14:02

    Your rule appears to be right, perhaps the client or server is stripping the last dot as spurious (checked on YT with Chrome, if you add a dot at the end of a video url (?=xxxxxxxxx to ?=xxxxxxxxx.) and press enter, it gets removed -- actually triggering a 303 HTTP response).

    In general, you should use only upper/lowercase letters and non-trailing dashes or dots in urls to compose the so-called slug, which is guaranteed to be handled correctly across all decent browsers and web servers.

提交回复
热议问题