How to redirect a URL in NGINX

- by

I’m a fan of easy to remember URLs, rather than long cryptic ones. For things I give our verbally or in chat I sometimes setup redirects using one of my domains and NGINX directives.

So when I’d like to point users to my 3D Shenanigans channel, I can tell them to go to rather than (because which human in their right mind could possibly remember the latter).

Thing is, I can never remember what the exact syntax is, so I thought I’d write myself a note for such future redirection setup. Here’s what the above example looks like when added as a directive to the subdomain:

location = / {

Note the use of the semicolon at the end of the line and the curly braces. I’m not that versed in NGINX, but every time I look at it I think “that’s easy”, and promptly forget only seconds later. I hope this helps both you and me to remember next time.

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.