Skip to main content
Web Server Tools

Nginx Redirect Generator

Create Nginx redirect rules for HTTP to HTTPS, www to non-www (or the reverse) and old URLs to new ones, with 301 or 302.

Free & instant No signup How to use FAQ
Not sure what to enter?

Choose the redirect you need, enter your domain and copy a correct Nginx rule - no regex guesswork.

How do I redirect in Nginx?

Nginx redirects are usually written with return 301 (permanent) or return 302 (temporary) inside a server or location block. This generator writes the correct rule for the four redirects websites need most: HTTP to HTTPS, www to non-www, non-www to www and an old page path to a new one.

How to create an Nginx redirect

  1. Choose the redirect type.
  2. Enter your domain (and the old and new paths for a page redirect).
  3. Pick 301 for a permanent move or 302 for a temporary one.
  4. Click Generate, add the rule to your server block and reload Nginx.

Related checks

After reloading Nginx, follow the redirect hop by hop with the Redirect Checker to make sure it lands on the right URL in a single step - chains of several redirects slow pages down and waste crawl budget.

Frequently Asked Questions

Use 301 when the move is permanent (HTTPS, www choice, a page that has moved for good) - search engines then transfer the old URL's ranking to the new one. Use 302 only for temporary moves, such as a short maintenance page.

Neither ranks better. What matters is choosing one and redirecting the other to it, so every page has a single address. Keep your canonical tags and sitemap on the same version.

return is simpler and faster: Nginx answers immediately without evaluating a regular expression. rewrite is only needed when part of the old URL has to be captured and reused in a complex pattern.
Share this tool:
Need a website for your business? Only $599