1 minute reading time (79 words)

Nginx Rewrite Rule - 301 Redirect One Page to Another URL

How to create a 301 permanent redirect for one page to another URL using the Nginx return directive 

Example: Nginx 301 Redirect one page to another URL

Old page https://youdomain.com/categories/azure/disable-welcome-to-acrobat-reader-message-using-registry
New page https://yourdomain.com/categories/guides/disable-welcome-to-acrobat-reader-message-using-registry

In this example, the redirect location is inside the server https block

location = /categories/azure/disable-welcome-to-acrobat-reader-message-using-registry {
  return 301 /categories/guides/disable-welcome-to-acrobat-reader-message-using-registry;
}
 

For redirecting a path for multiple URLs, see this guide:

Nginx Rewrite Rule - 301 Redirect to Another Path for Multiple URLs
https://techlabs.blog/categories/guides/nginx-rewrite-rule-301-redirect-to-another-path-for-multiple-urls

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 23 September 2023
You can help support this website by buying me a coffee!
Buy Me A Coffee