Redirect configuration examples for common web servers, CDNs, and deployment platforms.
The examples cover simple 301 redirects, regex and wildcard routing, geo-based redirects, and query parameter handling.
- Find your platform below, pick the recipe you need.
- Open the config file, read the comment block at the top (what it does, when to use it, gotchas).
- Copy the configuration, replace
example.comand the sample paths with your own, and deploy. - Validate before shipping - e.g.
nginx -t && systemctl reload nginxfor Nginx, or test one URL withcurl -Iand check theLocationheader and status code.
curl -sI https://example.com/old-page | grep -iE '^(HTTP|location)'- 301 Permanent -
return 301for static path moves - 302 Temporary -
return 302for temporary redirects - Regex & Wildcard -
rewritewith capture groups - Geo-Based - GeoIP country-based routing
- Subdomain - server name capture to path
- HTTPS Enforcement - HTTP → HTTPS with HSTS
- Query Params - preserve, strip, or rewrite query strings
- 301 Permanent -
Redirect 301for static moves - 302 Temporary -
Redirect 302for temporary redirects - Regex & Wildcard -
RedirectMatchwith patterns - Geo-Based - GeoIP country-based routing
- Subdomain - host header capture to path
- HTTPS Enforcement - HTTP → HTTPS
- www Canonicalization - www vs non-www
- Query Params - preserve, strip, or rewrite query strings
- Bulk Redirects CSV - upload hundreds of static mappings
- Dynamic Redirect Rules - expression-based pattern routing, geo, host, HTTPS
- redirects.json -
vercel.jsonredirects array: 301/302/308, splats, params, query, host - next.config.js - the same patterns via the Next.js
redirects()function, plus a geo middleware snippet
- _redirects - plain-text table: 301/302, splats, placeholders, query, geo/language, host
- netlify.toml - the same rules as typed
[[redirects]]blocks
More platform examples can be added as contributions.
- awesome-redirects - a curated list of redirect tools, guides, and resources
- migration-checklists - step-by-step checklists for domain and platform migrations
- RedirHub - hosted redirect management with a dashboard and API
Add your own recipe! See CONTRIBUTING.md.