Due to moving of a site, the old hoster created a redirect to the new location. However, there is a leading slash /
in the redirection and the former hoster is not able/willing to fix it. So I end up with all the redirects coming in like this:
http://sub.domain.com//path/to/file.html
So I tried to remove the leading slash:
using
mod_alias
RedirectMatch 301 ^//(.*)$ http://sub.domain.com/$1
using
mod_rewrite
RewriteEngine on RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{REQUEST_URI} ^(.*?)(/{2,})(.*)$ RewriteRule . %1/%3 [R=301,L]
Neither works. The latter removes multiple slashes inside the path, but not at the beginning.
There are already questions regarding slash removing, but they don't solve this problem:
- Issue In Removing Double Or More Slashes From URL By .htaccess
- .htaccess - how to remove repeated characters from url?
Does Apache somehow treat this case differently?
How do I get rid of one of the leading slashes?