> Using Netlify for Dynamic URL Redirects

// 386 words // 1 minute read

Using Netlify for Dynamic URL Redirects

With the recent domain switch that took place on this website, I needed to have a dependable setup to forward my old domain URLs to the new one. While using something like “URL forwarding” through your domain provider could work, it doesn’t natively support dynamic linking. Let me explain using a basic example:

Simple stuff. So, let’s breakdown how to easily set this up on Netlify for free.

Setting Up Netlify

  1. Create an account (or login to an existing one) and setup a new site1
  2. Change your “old” domain name nameservers to match Netlify’s (normally done through your domain register)
  3. Back in Netlify: under Domain Settings you need to add your custom “old” domain under the Custom domains section under Domain management
  4. Lastly, add the following content inside a _redirects file (no extension) to your website content/build (changing to your own domains, of course)* 301!

That’s it! Now Netlify will dynamically forward all your pre-existing URLs from your old domain to the new one. No pesky .htaccess files or running your own basic web server(s)!

Hopefully this helps others trying to dynamically redirect their domains without the headache.

  1. I normally set this up through Github / git hosting ↩︎

Leave a comment

To make a comment, please send an e-mail using the button below. Your e-mail address won't be shared and will be deleted from my records after the comment is published. If you don't want your real name to be credited alongside your comment, please specify the name you would like to use. If you would like your name to link to a specific URL, please share that as well. Thank you.

Comment via email