Home › Web & Hosting › Redirects (_redirects)
Web & Hosting
Redirects (_redirects)
Generate a _redirects file for Cloudflare Pages or Netlify — path redirects for pages you've moved — plus the Cloudflare Redirect Rule for a canonical host (www↔apex). Getting redirects right protects your SEO when URLs change.
Try it now
Worked example
# _redirects — Cloudflare Pages / Netlify. Put in your site root.
# Format: /from /to status
/old /new 301
# Optional single-page-app / custom 404 fallback:
# /* /404.html 404
# ---- Canonical host + HTTPS (Cloudflare -> Rules -> Redirect Rules) ----
# Host-level redirects are domain-wide, so they go in a Redirect Rule, not _redirects:
# When: (http.host eq "www.example.com")
# Then: Dynamic redirect -> concat("https://example.com", http.request.uri.path) 301
Learn the method
Inputs
- Your domain
example.com - Canonical host
www → apex / apex → www / none - Redirect type
301 permanent / 302 temporary - Custom redirects (from>to, comma-sep)
/old>/new
Frequently asked
Why is the www↔apex rule separate?
Host-level redirects are domain-wide, so they belong in a Cloudflare Redirect Rule, not the path-level _redirects file. Both are generated here.
What status code?
301 (permanent) for moved pages, so search engines pass along ranking. Use 302 only for temporary moves.