Published under Statamic.
You can use Statamic's redirect tag plus a custom blueprint to setup dynamic HTTP redirects on your Statamic website.
Let's say you're building a CMS for a client, and they need the ability to create redirects on the fly, eg:
We can do this using Statamic's
redirect tag. The premise is essentially:
Create a blueprint that has a single field which we'll input our destination URL into
We create a new layout file that only has a
redirect tag in it
Create a collection to store the redirects for the site
The slug of each redirect entry will be the "from" URL
First, we need to create the blueprint. Here's what I am using:
Next, we need to create a new layout file. The location of this file depends on your site setup, but for me, the file goes in
Finally, we need to create the collection for the redirect entries. Feel free to use the Control Panel to do this. I'll post my collection's YAML file for reference:
That's it! Now you can create as many redirects as your heart desires! Here's a file showing how I redirect