Redirecting
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
noReturn
parameter 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)