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
  1. Go to redirection rules.
  2. Select custom rule
  3. Select URI query params.
  4. Write the expression in destination URL
concat("https://example.com", http.request.uri.path)

See this screenshot

Screenshot of Redirection rule in CF

We checked the redirect for both amp versions of URLs and worked without any issues.