The variable% {REQUEST_URI} decreases when you add a slash when preparing it. Thus, the condition RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ Will never match, because for a request such as http://domain.org//// , the REQUEST_URI variable is reduced to simply / . Try using the THE_REQUEST variable:
RewriteCond %{THE_REQUEST} ^([AZ]{3,9})\ (.*)//([^\ ]*) RewriteRule ^ %2/%3 [R=301,L]
In addition, the prefix (leading slash) is removed from the request URI when the rewrite rules are in the htaccess file, therefore the RewriteRule . %1/%2 [R=301,L] rule RewriteRule . %1/%2 [R=301,L] RewriteRule . %1/%2 [R=301,L] will never match, because for regular expression . At least one character is required. When the URI is / , and the leading slash is separated, the URI that is used for matching in the URL is an empty string. Thus, using ^ or (. *) , Or something equivalent to the regex "all that doesn't need anything".
source share