问题
I know how to do it with PHP, how to replace multiple slashes from URL to only one, for example:
http://example.com/uri1////////uri2/uri4
replace to:
http://example.com/uri1/uri2/uri4
etc. How do to it with htaccess?
回答1:
Place this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
来源:https://stackoverflow.com/questions/20353719/removing-multiple-slashes-with-htaccess