开发者

How to make this .htaccess rule work fine without manual adding there path `/some-dir/` or `RewriteBase /some-dir`?

I have http://localhost/some-dir/.htaccess RewriteRule ^(.+)/$ /some-dir/$1 [R=301,L] to remove trailing slash from URLs end.

How can I improve the same think with simple .htaccess in http://localhost/some-dir/.htaccess without manual adding there path /some开发者_如何学Python-dir/ or RewriteBase /some-dir? so that this rule works fine if I use it in any server path, like http://localhost/.htaccess or http://localhost/some-dir/else-path/etc/.htaccess etc.


You could use REQUEST_URI instead:

RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^.+/$ %1 [R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜