How to redirect a URL in NGINX

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 https://3ds.wpguru.tv rather than https://www.youtube.com/channel/UCmBV6fLZMzCaIEXzF1SSJuQ/ (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:

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.

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!