Answers.Body: <p>For this, my <a href="https://github.com/nystudio107/retour" rel="nofollow">Retour</a> plugin would work well, because it has a FieldType that you can attach to existing Entries, and do the redirect based on data from the entries.  </p>
  
  <p>So you can set up a rule in the FieldType like <code>.*RecipeID={recipeid}</code> as the default Legacy URL Pattern for the FieldType, and it'll pull the value from the <code>{recipeid}</code> field in each entry, and create a redirect for it to the new entry.</p>
  
  <p>It also doesn't do anything unless a 404 exception actually occurs.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-25T20:29:31.023Z
Answers.LastActivityDate: 2016-04-25T20:29:31.023Z
Answers.UserDisplayName: andrew.welch
Answers.Body: <p>Take a look at Craft's <a href="http://buildwithcraft.com/docs/templating/tags#redirect">redirect</a> function:</p>
  
  <pre><code>{% redirect '/' %}
  </code></pre>
  
  <p>In your case it would look like this:</p>
  
  <pre><code>{% redirect 'neptune/' ~ id ~ '/confirm' %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-15T16:07:48.977Z
Answers.LastActivityDate: 2014-06-15T16:07:48.977Z
Answers.UserDisplayName: Victor
Body: <p>We have a some conditional logic for a dashboard style setup. We have urls like : </p>
  
  <pre><code>neptune/{id}/details
  neptune/{id}/options
  neptune/{id}/confirm
  </code></pre>
  
  <p>etc..</p>
  
  <p>The actual urls accessible depend on the status of the elements in question, and the whole process has a flow setup - the user has to go through each part in turn, ie. details > options > confirm, however they can go back and revise and drop out entirely and pick up where they left off later. </p>
  
  <p>This all works fine, but to smooth out things we'd ideally have a way to automatically force a redirect from a urls based on the current state. If this were ExpressionEngine we'd have a tag like : </p>
  
  <pre><code>{redirect="neptune/{id}/confirm"}
  </code></pre>
  
  <p>What's the equivalent Craft/Twig setup? Or is there an alternative better setup. </p>
  
  <p><strong>Note</strong> : this isn't for the main flow of the user, only needed for the actual edge cases where a user may revisit (ie. manually) an out of flow url somehow, so isn't related to the core logic. </p>
  
Tags: <templating><redirect>
Title: How to automatically redirect a url based on dynamic content
ThreadText: # How to automatically redirect a url based on dynamic content
  
  (Asked by: username_0 on 2014-06-15)
  
  We have a some conditional logic for a dashboard style setup. We have urls like :
  
  ```
  neptune/{id}/details
  neptune/{id}/options
  neptune/{id}/confirm
  
  ```
  
  etc..
  
  The actual urls accessible depend on the status of the elements in question, and the whole process has a flow setup - the user has to go through each part in turn, ie. details > options > confirm, however they can go back and revise and drop out entirely and pick up where they left off later.
  
  This all works fine, but to smooth out things we'd ideally have a way to automatically force a redirect from a urls based on the current state. If this were ExpressionEngine we'd have a tag like :
  
  ```
  {redirect="neptune/{id}/confirm"}
  
  ```
  
  What's the equivalent Craft/Twig setup? Or is there an alternative better setup.
  
  **Note** : this isn't for the main flow of the user, only needed for the actual edge cases where a user may revisit (ie. manually) an out of flow url somehow, so isn't related to the core logic.
  
  **Tags:** templating, redirect
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-06-15. Score: 10 | Accepted answer
  
  Take a look at Craft's [redirect](http://buildwithcraft.com/docs/templating/tags#redirect) function:
  
  ```
  {% redirect '/' %}
  
  ```
  
  In your case it would look like this:
  
  ```
  {% redirect 'neptune/' ~ id ~ '/confirm' %}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-04-25. Score: 2
  
  For this, my [Retour](https://github.com/nystudio107/retour) plugin would work well, because it has a FieldType that you can attach to existing Entries, and do the redirect based on data from the entries.
  
  So you can set up a rule in the FieldType like `.*RecipeID={recipeid}` as the default Legacy URL Pattern for the FieldType, and it'll pull the value from the `{recipeid}` field in each entry, and create a redirect for it to the new entry.
  
  It also doesn't do anything unless a 404 exception actually occurs.
  
  
  ---
  
  