When moving your content - your blog or website for example - to a new system, it’s ideal to keep things working as close to as they used to as they can. That way, any links that have been posted to your old content will still direct them to the same stuff on your new website.
An issue that can crop up is when your different content management systems have different ways of storing posts…
For instance, for an old post of mine, the way the
Jekyll template was configured was using directory paths that looked like:
Under my new system, however, the address of this post looks like:
It is possible to use page rules to take the information as given by the old address and automatically redirect users to the new content. If you use CloudFlare for your DNS, it is reasonably easy to do via the control panel.
When a user attempts to visit a page that matches your page rule, you can set it to trigger a response. Perhaps to check if the browser is compatible, or if the user is a human. In our case, we can use this to automagically forward our user to the correct page.
To do this, compare the web addresses to see what can be reused in your corrected link
Old: http://www.tteoh.com/veterinary/2016/01/20/microchips-authorised-implanter/ \__ / / / / \ / / / / New: https://tteoh.com/post/2016-01-20-microchips-authorised-implanter/
Using wildcards, we can match the addresses of interest to catch not only one post but all post. To do this, an asterisk (
*) can be used.
http://www.tteoh.com/veterinary/2016/01/20/microchips-authorised-implanter/ tteoh.com/* /20* /* /* /* /
It has been spaced as above for ease of visualisation, but what it’ll look like in the matching box entry will be more like
We can retrieve the information matched using our asterisks using %1 for the first match, %2 for the second match and so forth. In this case, we want to use information covered by asterisk 2, 3, 4, and 5, while at the same time updating the encrypted address of the link and discarding the old metadata information in the address:
Set it as a permanent redirect (301) and you’re done! Feel free to test it out with this old link.