Nginx Redirect Generator
Generate Nginx redirect rules - 301/302, HTTP to HTTPS, www to non-www, or old path to new path.
Choose the type of redirect you need - this tool generates the exact Nginx `return` or `rewrite` directive for it.
For a full server block (not just a redirect), see the Nginx Config Generator.
What Is an Nginx Redirect?
An Nginx redirect tells browsers and search engines that a URL has moved - a 301 (permanent) redirect passes on most SEO value to the new URL, while a 302 (temporary) redirect signals the move isn't permanent.
Why Use This Tool?
Nginx redirect syntax (return vs rewrite, and correct regex capturing for path-based redirects) is easy to get subtly wrong, which can create redirect loops or lose query parameters unexpectedly. This tool generates the correct directive for common cases.
How to Use It
- Choose a redirect type: HTTP to HTTPS, www to non-www (or the reverse), or a specific old-path-to-new-path redirect.
- Enter your domain and any relevant paths.
- Copy the generated Nginx directive into the relevant
serverblock.
Limitations
This generates the redirect directive only, not a full server block - it needs to be placed inside an existing server { } block. Always test with nginx -t before reloading.