Cloudflare ignores nginx rules of slashes rewriting

Before I had my website on cloudflare my nginx rule was working perfectly, but today I was doing some checks and for my surprise the trailing slashes was not being rewritten. What is happening? What am I doing wrong?
My rules is the following:

merge_slashes off;
rewrite (.*)//+(.*) $1/$2 permanent;

Haven’t heard and even not used that one.

Shouldn’t it be like below, if so?:
rewrite ^(.*)//+(.*)$ $1/$2 permanent;

Or try with using the break instead of permanent.

Are you trying to match the scheme HTTPS and/or HTTP with it here or some URLs which contain like

And I am not sure why wouldn’t it work with Cloudflare, but I assume it could be due to the HTTP/HTTPS here.

May I also ask was your website working with HTTPS before moving to the Cloudflare?
And over which port you app works in Nginx?

Any screenshot of the error?

1 Like

Do you have URL Normalization enabled?

This was the stackoverflow answer that helped me with this problem.

I am trying to rewrite urls in my website like so would go to

Was working with lets encrypt as far as I remember.

The following:

Yes, I do have. And for a blackslash rewrites just fine. But, multiples backslashes became the same amount of slashes.\\\\\directory\\\\\ rewrites to

This solved. Thank you.

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