I can remove multiple slashes anywhere in URL using:
RewriteCond %{REQUEST_URI} ^(.*?)(/{2,})(.*)$
RewriteRule . %1/%3 [R=301,L]
But it doesn't work for multiple slashes after the domain
I have tried
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]
and
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ (.*)//([^\ ]*)
RewriteRule ^ %2/%3 [R=301,L]
both produce the expected rewirting when going from
domain.com/////hello
to
domain.com/hello
but from
domain.com/////héllo
the result is encoded
domain.com/h%25c%25allo
How to prevent accented characters to get encoded when removing multiple slashes after domain ?
EDIT: pear to anubhava's answer
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*) [NC]
RewriteRule ^ %1/%2 [R=301,L,NE]
The accented character is protected and trimed with succes with more than to repeated slashes
domain.com////////héllo
but not with only 2
domain.com//héllo