Nginx Redirect Generator
Generate Nginx redirect rules using the return directive. Handle individual path redirects, HTTP→HTTPS, and www/non-www preferences.
⚠️ Test Warning: Always test Nginx redirect rules on a staging server first. Use
nginx -t to check for syntax errors before reloading. Incorrect redirects can take your site offline. Keep backups of your server block configuration files.
Redirect Configuration
The path to redirect FROM (e.g., /old-page, /blog/old-post).
The full destination URL.
Global Rules
Nginx Redirect Methods
Nginx offers several ways to configure redirects:
return 301 $url;— Best for simple, single-path redirects. Fastest method, evaluated at the very start of request processing.rewrite ... permanent;— More flexible for pattern-based redirects using regex. Slightly slower but more powerful.return 301 https://$host$request_uri;— Standard HTTP→HTTPS redirect.
Best Practices
- Prefer
returnoverrewritewhen a simple path redirect is sufficient — it's faster. - Place specific redirects before catch-all rules in your config.
- Always use 301 for permanent changes and 302 for temporary ones.
- Avoid redirect chains — each hop adds latency.