Shrtn is a small PHP appliance to handle redirects between short URL paths on one domain, to full URLs on any other.
It's a port of shrtr
, which was the same thing but written in an ancient version
of ruby that's now annoying to deploy.
It reads in a Yaml configuration file containing static mappings, and will 301 redirect to the destination when provided.
Any other URL is redirected to a specified fall-back.
The YML mappings for my own use are generated by a Jekyll static site, but could either represent a manual list, or be replaced with a base-60 conversion where IDs make for appropriate slugs.
Configure config/shrtr.json
to point to your source of short URL mappings, and the
URL to redirect to in the event of a missing mapping (e.g. 404
handler on your site.)
The mappings file is a simple YAML configuration file:
shorturls:
-
id: 1dkfL_
url: https://example.com/full/article/23235.html
-
id: 1qnuL0
url: https://example.com/full/article/523232.html
-
id: 1oY6A0
url: https://example.com/full/article/51212.html