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]
精彩评论