Issue with double slash redirections

Hello,

I’m having problems in my site with double slash redirections and Cloudflare cache.

In my .htaccess I’m redirecting all urls with double slash to the same url without the double slash.

rule 1: remove multiple leading slashes (directly after the TLD)
RewriteCond %{THE_REQUEST} \s/{2,}
RewriteRule (.*) $1 [R=301,L]

rule 2: remove multiple slashes in the requested path
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule (.*) %1/%2 [R=301,L]

When I go to url with double slash, Cloudflare is caching the redirection for the double and single slash url, so that is generating a redirections loop.

If I go to url with single slash, Cloudflare is caching the content and if then I go to the url with double slash, Cloudflare returns content instead of redirection to the single slash.

Why for my Cloudflare cache the url https://www.mydomain.com/path//path2 is the same url that https://www.mydomain.com/path/path2

Thanks to all.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.