Wrangler vs Page rule for trailing slash redirect

Hi there! I have a website on workers, my wrangler file has force-trailing-slash param. Cloudflare creates 307 redirect from non-trailing-slash to a trailing-slash version. I want it to be 301 redirect, but I am not sure how to configure a page rule this way and also wouldn't it create confusion between wrangler and page rule trying to do the same thing? Or one of them has priority? Also, same goes for http to https redirect. I have always use HTTPS toggle on, but it uses 307 redirect. Should I create a page rule with a desired 301 for this matter? What should I do with always use HTTPS in that case, leave it be or turn it off? ^^
6 Replies
Laudian
Laudian4mo ago
The http -> https redirect happens on DNS level, not via http. No redirect/page rule you create will change that, as the DNS lookup happens before any requests are actually sent.
TWEL
TWELOP4mo ago
Thank you for a hint. This DNS level redirect depends on what mode am I using, right? And if it is full or full strict then redirect does not occur and the question remains relevant? @Laudian
Laudian
Laudian4mo ago
No, the redirect has nothing to do with the SSL mode. Cloudflare publishes an https dns record for your domain that tells Chrome that the site is available over https. Chrome will then create a 307 (internal redirect).
TWEL
TWELOP4mo ago
Thank you for taking time with me. So there is no point of having page rule and “always use https” toggle whatsoever?
Laudian
Laudian4mo ago
There is. The DNS redirect is specific to browsers. Most other software will not use it. So you should still have it in place, but you won't be able to use it to override the DNS redirect.
TWEL
TWELOP4mo ago
Thank you for the explanation. Puzzles fell into place now. I will configure page rule to set 301 redirect and opt out of “always use https” since those are interchangeable I guess

Did you find this page helpful?