htaccess - Remove multiple slashes after domain with encoded accented characters

前端 未结 2 1970
闹比i
闹比i 2021-01-15 03:26

I can remove multiple slashes anywhere in URL using:

RewriteCond %{REQUEST_URI} ^(.*?)(/{2,})(.*)$
RewriteRule . %1/%3 [R=301,L]

But it doe

相关标签:
2条回答
  • 2021-01-15 03:40

    This rule should work for you:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)/+(/[^\s]+) [NC]
    RewriteRule ^ %1%2 [R=302,L,NE]
    

    This will do these redirections:

    1. /////help => /help
    2. /////héllo/////abc/////123 => /héllo/abc/123
    0 讨论(0)
  • 2021-01-15 03:56

    anubhava's answer is the shortest but alternatively this one is also working:

    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,NE]
    
    0 讨论(0)
提交回复
热议问题