Redirecting
Updated Published 1 min read
While working on my api, I figured out a way to set up a system of dynamic redirects with alias matching. This means I can define multiple links that all redirect to a specific URL, for example /instagram, /ig and /insta all redirect to my instagram profile. The advantage of this is that I don't have to remember a specific term, any other synonym I defined will work too.
This was made possible by setting up a second domain (muensterer.link), that forwards requests to the /redirect route of my api. I also modified the 404 page on my homepage to automatically attempt a redirect if the page does not exist.
It even passes on the rest of the URL, so instead of going https://github.com/dnnsmnstrr/dotfiles I can just type muensterer.link/gh/dotfiles. This "autoexpansion" of URL components has proven to be very useful.
There are different ways to access these redirects:
next.muensterer.xyz/api/redirect- the direct api urlhttp://api.muensterer.xyz/redirect- the aliased urlhttps://muensterer.xyz/redirect- this is possible through a repository which hosts a simple HTML file via pages and redirects to muensterer.link
muensterer.link- forwards to the api url
- 404 on muensterer.xyz
- If a page is not found, there is an automatic redirect attempt with a
noReturnparameter to avoid infinite loops back to the 404 page
- If a page is not found, there is an automatic redirect attempt with a
Ideas
- check for fallbacks in projects and notes (Github API)
Links
Links from this note 1
Links to this note 5
- APIMy personal api is available at https://dnnsmnstrr.vercel.app/api/ Available routes: Route Description /dennis Returns information about me /events A list of events in my life…
- CloudflareSince July 2022, my website is set up to use Cloudflare. It supposedly makes accessing the site faster, but I mainly like it for the DNS controls, which will hopefully be able to…
- GistGithub's gist service let's you store text files that can be embedded in websites. I often store code snippets or small scripts I created here, so they can be found and used by…
- PopclipExtensions Popclip offers many extensions, I like these: Activate alfred Brackets Character / Word Count Formatting Run in Terminal Sort selected Lines ChatGPT ai Extension…
- My websiteView my homepage Hosting on Github pages is free, but domains usually are not, so I tend to switch domains fairly regularly (whenever renewal would be too expensive). Due to this…