1

I'm upgrading a relatively large, but low budget, local government website from Craft 2 to Craft 3. The major remaining pain point is a replacement for the Craft 2 Reroute plugin, which is not available in the Craft 3 Plugin Store.

The main use of Reroute was redirecting existing URLs to other URLs within the site (and against my preferences to external URLs as well). The site is built around a strong hierarchy and quite often the parent page of "section" is redirected to the first child page (because the parent page serves as a conceptual folder and has no content on its own). And because Reroute worked well old entries/pages were not always deleted, just redirected to their new location or replacement pages by the content editors.

In Craft 3 we have Redirect plugin, Retour and Sprout Redirect, but as far as I can tell they only redirect non-existing URLs.

Now I could add a redirect Entry field to the various sections, and manually manage it that way, but it is quite a lot of work in the midst of an upgrade done by one little person (me).

So have I misunderstood that there are no existing plugins that will redirect existing URLs? Or am I missing an obviously easy way of doing this?

3
  • Retour (and I assume Sprout Redirect) doesn't attempt to handle a redirect until a 404 has officially been triggered. This means that the plugin doesn't get in the way or do any extra work until it's absolutely needed (which is theoretically a good thing).
    – Lindsey D
    Commented Jun 10, 2019 at 20:52
  • 1
    I'm not sure I follow why you'd want to redirect away from an existing entry. Would it be possible to just disable the entry, and allow a 404 to be triggered?
    – Lindsey D
    Commented Jun 10, 2019 at 20:53
  • The reason that the entry remains live is that it is used as part of the site hierarchy and thereby show as menu items, and in site map and other navigation structures we have. In many sites I have worked in I am given hierarchies and the top page on each section is effect a folder or index page/item - so to prevent an extra click to the user they are redirected most often to the first child. On other occasions content editors want to send users from a child menu item across to another area in the site - a sort of a cross reference. Commented Jun 11, 2019 at 21:12

1 Answer 1

4

Based on your comments, I'd recommend creating a new entry type in your section.

Create a "Redirect" entry type which only contains a URL link (or an Entry field) so the page knows how to handle the redirect. For any entries that need to be converted to a redirect, simply swap the entry type to use this instead.

Then you can simply map that entry type to a redirect template:

{% redirect entry.newUrl %}

I've done this, and it works well.

1
  • Thanks @lindsey-d. I had gone someway down that road, and thanks to Feedme I can import the data (important because while I am building the upgrade off to the side the production content is being updated which means I can't have too much manual entry to do) Commented Jun 11, 2019 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.