Answers.Body: <p>There are a few plugins which can handle this, but <strong>Retour</strong> is the newest and shiniest!</p>
  
  <blockquote>
    <p><a href="https://github.com/nystudio107/retour">https://github.com/nystudio107/retour</a></p>
  </blockquote>
  
  <p>It's from the same developer as SEOmatic... he puts a lot of love &amp; attention into his plugins, so you know it's safe to rely on.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-21T20:28:51.347Z
Answers.LastActivityDate: 2016-06-21T20:28:51.347Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>Craft has a <a href="https://craftcms.com/docs/templating/redirect">twig redirect tag</a>.  </p>
  
  <p>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. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-22T04:19:48.713Z
Answers.Text: I stand corrected... this is exactly how you'd do it without a plugin!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-21T23:01:59.413Z
Answers.LastActivityDate: 2016-06-21T23:01:59.413Z
Answers.UserDisplayName: Moto_Nomad
Body: <p>Within Craft, I am renaming the top-level entry URL format for a section from <code>legacy-subdirectory/{slug}</code> to <code>new-subdirectory/{slug}</code>. How do I redirect traffic from the legacy URL to the new format within Craft?</p>
  
  <p>I am aware that I may use the rewrite rule within <code>.htaccess</code> in exchange for a slight performance hit:</p>
  
  <pre><code>    RewriteRule ^legacy-subdirectory/(.*)$ /new-subdirectory/$1 [R=301,NC,L]
  </code></pre>
  
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-21T20:41:09.713Z
Comments.Text: 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.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-22T15:15:47.600Z
Comments.Text: 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``](https://httpd.apache.org/docs/current/mod/core.html#allowoverride) to ``None`` in the server's main config.
Comments.UserDisplayName: RitterKnight
Tags: <redirect><server><apache>
Title: How do I redirect traffic from a legacy category URL to a new category URL?
ThreadText: # How do I redirect traffic from a legacy category URL to a new category URL?
  
  (Asked by: username_0 on 2016-06-21)
  
  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.
  
  **Tags:** redirect, server, apache
  
  > **Comments:**
  > **username_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.  
  > **username_2**: 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``](https://httpd.apache.org/docs/current/mod/core.html#allowoverride) to ``None`` in the server's main config.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2016-06-21. Score: 6 | Accepted answer
  
  Craft has a [twig redirect tag](https://craftcms.com/docs/templating/redirect).
  
  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.
  
  > **Comments:**
  > **username_1**: I stand corrected... this is exactly how you'd do it without a plugin!  
  
  ---
  
  ### Answer by username_1 on 2016-06-21. Score: 7
  
  There are a few plugins which can handle this, but **Retour** is the newest and shiniest!
  
  > <https://github.com/nystudio107/retour>
  
  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.
  
  
  ---
  
  