Categories
NGINX Ubuntu Server

Simple 301 redirect with NGINX

Just a quick post on 301 redirects in NGINX – for a single URL the syntax is pretty easy as it reflects most other location blocks you’ll be setting up anyway:

location /old/path/ {
    return 301 https://tonymerryfield.co.uk/new/path/;
}

This is a quick way to ensure old URLs still point to relevant content and you retain some of your PageRank too.

If you have other quick solutions to 301s post them below and I’ll add them to this post.