简体   繁体   中英

Removing multiple slashes with htaccess

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?

Place this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s[^?]*//
RewriteRule ^.*$ /$0 [R=301,L,NE]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM