DEV Community

Cover image for Let's deploy the simplest URL redirection service to Netlify!
Thai Pangsakulyanont
Thai Pangsakulyanont

Posted on • Originally published at

Let's deploy the simplest URL redirection service to Netlify!

Sometimes it's a good idea to post links under your own domain, so that you can change the link's target when needed1.

For example, I have a Ko-Fi page at but I never link to that URL directly; I use instead. Should I ever decide to use something else2, I only need to change the link destination.

One simple, low-code way to accomplish this is use Netlify's redirect feature.

  1. Create a GitHub repo and create a file public/_redirects:

     /youtube   302
     /coffee                                    302
  2. Create a Netlify site linking to the GitHub repo and set up your domain.

  3. There is no step 3.

The _redirects file has a simple, machine-and-human-readable, plain-text format. To add or change links, just update the file on GitHub. I find this approach powerful because I can also update this file programmatically using GitHub's API, and teams can collaborate on this file like how they collaborate on code. One downside is that this approach doesn't track how many people used the link, we you'd have to track from the destination instead.

  1. Some URL shortener services doesn't allow you to change the link's destination unless you pay them money 

  2. like Patreon or GitHub Sponsors (the latter of which is not available in my country yet) 

Top comments (0)