Within Craft, I am renaming the top-level entry URL format for a section from legacy-subdirectory/{slug} to new-subdirectory/{slug}. How do I redirect traffic from the legacy URL to the new format within Craft?

I am aware that I may use the rewrite rule within .htaccess in exchange for a slight performance hit:

    RewriteRule ^legacy-subdirectory/(.*)$ /new-subdirectory/$1 [R=301,NC,L]

I would prefer handling this within Craft. As there is only one slug in which I need the redirect, I would prefer handling this without plug-ins.

  • 1
    I don't think it could be done without a plugin. Craft's routing can handle wildcards on the way in, but not on the way out. At the very least, you'd need to write your own Controller action to handle the wildcard.
    – Lindsey D
    Commented Jun 21, 2016 at 20:41
  • It should be noted that .htaccess is going to be much faster than going through Craft/PHP because Apache already knows about the redirect before it passes it off to PHP. If you want speed up your site further, ditch your .htaccess and move whatever is in there to your vhost configuration and set AllowOverride to None in the server's main config. Commented Jun 22, 2016 at 15:15

2 Answers 2


Craft has a twig redirect tag.

You should be able to create a "redirect" template that handles redirects based on {slug} and/or url segments and then use Craft routes to direct "legacy-subdirectory" requests to your redirect template. I have not tested this.

  • I stand corrected... this is exactly how you'd do it without a plugin!
    – Lindsey D
    Commented Jun 22, 2016 at 4:19

There are a few plugins which can handle this, but Retour is the newest and shiniest!


It's from the same developer as SEOmatic... he puts a lot of love & attention into his plugins, so you know it's safe to rely on.

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.