aboutsummaryrefslogtreecommitdiff
path: root/posts/netlify-urls.md
diff options
context:
space:
mode:
authorBradley Taunt <bt@btxx.org>2024-06-06 08:05:12 -0400
committerBradley Taunt <bt@btxx.org>2024-06-06 08:05:12 -0400
commit6b742c459266b18e2b375b35205ce8a6c02f0452 (patch)
treeb16fbb9a045e33dd6c97eb5ab72e6ff4d9237ea3 /posts/netlify-urls.md
Initial commit
Diffstat (limited to 'posts/netlify-urls.md')
-rw-r--r--posts/netlify-urls.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/posts/netlify-urls.md b/posts/netlify-urls.md
new file mode 100644
index 0000000..5ccf903
--- /dev/null
+++ b/posts/netlify-urls.md
@@ -0,0 +1,34 @@
+# Using Netlify for Dynamic URL Redirects
+
+2021-12-03
+
+With the [recent domain switch](/minor-website-changes/) 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:
+
+- A user clicks on a link that targets a post on your old domain:<br> `olddomain.com/random-post`
+- You want that link to forward using the same permalink structure:<br> `newdomain.com/random-post`
+- "URL forwarding" through your domain provider **does not** support this
+
+Simple stuff. So, let's breakdown how to easily set this up on Netlify *for free*.
+
+## Setting Up Netlify
+
+- Create an account (or login to an existing one) and setup a new site[^1]
+- Change your "old" domain name nameservers to match Netlify's (normally done through your domain register)
+ - `dns1.p03.nsone.net`
+ - `dns2.p03.nsone.net`
+ - `dns3.p03.nsone.net`
+ - `dns4.p03.nsone.net`
+- Back in Netlify: under **Domain Settings** you need to add your custom "old" domain under the **Custom domains** section under **Domain management**
+- Lastly, add the following content inside a `_redirects` file (no extension) to your website content/build (changing to your own domains, of course)
+
+
+ https://olddomain.com/* https://newdomain.com/:splat 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.
+
+## Refs
+
+1. I normally set this up through Github / git hosting