How to redirect to canonical hostname using redirect rules?

Usually I create two page rules for redirection to the canonical hostname:* to$1
and* to$1

But I need the page rules for something else and I don’t want to use Always Use HTTPS because in my experience it interferes with workers and because I just want one redirect when the unsecured naked domain is used to access the site. I noticed that there is a new redirect rules feature. How can I use redirect rules to do this?

I migrated my redirects from Page Rules to Bulk Redirects, but it looks like you could use Single Redirects even more easily.

I don’t see any documentation on how to redirect to the same request uri as the original request. I only see a checkbox that says Preserve query string.

It looks like you may need Bulk Redirects for that after all. I know it has an option to preserve the path.

These new Cloudflare Rules are confusing everybody!

You can preserve the path with a Single Redirect too, but it takes an expression using http.request.uri.path

With the above Redirect Rule, all naked domain requests will be redirected to their www. equivalent, regardless of http/https

Here’s an example where visitors are redirected based on Geo IP to localized versions of the website:

1 Like

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