Nginx redirect one path to another

Direct quote from Pitfalls and Common Mistakes: Taxing Rewrites:

By using the return directive we can completely avoid evaluation of regular expression.

Please use return instead of rewrite for permanent redirects. Here’s my approach to this use-case…

location = /content/unique-page-name {
  return 301 /new-name/unique-page-name;
}

Leave a Comment