Efficient redirect URL scheme using Page Rule

Hi!

We are using Cloudflare Page Rule to perform some dynamic redirection.
We have implemented redirection mechanism using Cloudflare instead of native CMS (Webflow) feature to keep the URL chain length as short as possible, following SEO best practices.

As an example, we are transforming a URL such as https://fygr.io/notre-equipe/ into https://www.fygr.io/notre-equipe (add www + remove trailing /).
This used to work just fine and this URL reformatting was performed into a single step.

For a few days, it continues to work but formatting is now split into two steps (which is not great from an optimal point of view).

https://fygr.io/notre-equipe/ โ†’ https://www.fygr.io/notre-equipe/ โ†’ https://www.fygr.io/notre-equipe

instead of https://fygr.io/notre-equipe/ โ†’ https://www.fygr.io/notre-equipe

Our Page rule is as follows:
fygr.io/*/
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.fygr.io/$1)

Has anyone a hint about this?
Many thanks!

Hi,

With Page Rules, order matters.

Can I assume you have another rule to redirect URLs that do not have a trailing slash, but also do not point to www.?

example.com/path -> www.example.com/path

If so, the Page Rule for the most specific URL, to perform the redirect for URLs with the trailing slash, should be placed above the rule for URLs without it. See if that fixes the problem.

Also, you should consider Redirect Rules, as Page Rules have a limited ability to handle more complex logic that you may need to include down the road, such as considering query string or specific subdirectories for exclusions.

2 Likes