Cloudflare handles 301 redirects super easy on the top layer. Lately we encountered unique problem of removing amp pages and doing 301 direct of all canonical URLs. We received proper canonical tag warnings in google because of this and hurt our rankings.
Alternate page with proper canonical tag
Cloudflare did it on the fly. No requirement to use plugins that overload the server.
Our case needed removing all amp query strings and redirect to original url (mobile ) version in wordpress.
?amp or ?amp=1 -> Original URL path
- Go to redirection rules.
- Select custom rule
- Select URI query params.
- Write the expression in destination URL
concat("https://example.com", http.request.uri.path)
See this screenshot
We checked the redirect for both amp versions of URLs and worked without any issues.