开发者

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

开发者 https://www.devze.com 2023-02-06 01:43 出处:网络
I have http://localhost/some-dir/.htaccess RewriteRule ^(.+)/$ /some-dir/$1 [R=301,L] to remove trailing slash from URLs end.

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

精彩评论

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