Removing multiple slashes with htaccess

独自空忆成欢 提交于 2019-12-12 02:55:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!