Answers.Body: <p>Update line 5 to <strong>concatenate</strong> the path/URL with the variable <strong>workTitle</strong>.</p>
  
  <p><code>{% redirect "/visit/index?artwork=" ~ workTitle %}</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-04T23:58:24.150Z
Answers.Text: FWIW: You can also interpolate the variable, like this: `{% redirect "/visit/index?artwork=#{workTitle}" %}`. This syntax might be preferable if you have many variables to include in the query params.
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-05T00:00:47.347Z
Answers.Text: Also… the `url` Twig helper might come in handy! `{% redirect url('/visit/index', { artwork: workTitle }) %}`. The added benefit here is that it discards null values, and keeps your URLs nice and trim.
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-10T06:22:30.010Z
Answers.LastActivityDate: 2017-04-10T06:32:58.020Z
Answers.LastEditDate: 2017-04-10T06:32:58.020Z
Answers.UserDisplayName: Selvin Ortiz
Answers.Body: <p>I think:</p>
  
  <pre><code>{% redirect "/visit/index?artwork="~workTitle %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-10T06:26:11.350Z
Answers.Text: Beat me to it
Answers.UserDisplayName: Selvin Ortiz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-10T06:30:54.407Z
Answers.Text: Apparently not. @SelvinOrtiz I think you had me by 3-4 seconds. Might want to add the initial "{" to your code.
Answers.UserDisplayName: AbbeyDesign
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-10T06:32:51.967Z
Answers.Text: And you took the time to explain what you were doing, mine was a limp "I think". Sad.
Answers.UserDisplayName: AbbeyDesign
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-10T06:22:42.777Z
Answers.LastActivityDate: 2017-04-10T06:22:42.777Z
Answers.UserDisplayName: AbbeyDesign
Body: <pre><code>1.{% set workTitle = craft.request.getLastSegment()  %}
  2.{% if currentUser %}
  3.     {{workTitle}}
  4.{% else %}
  5.  {% redirect "/visit/index?artwork=workTitle" %}
  6.{% endif %}
  </code></pre>
  
  <p>Each line of code are working fine except the line 5. I set a value on line 1. Line 3 returns the set value but on line 5 when am trying to redirect it doesn't return correct path.
  Redirect returns the below path instead of the returning the set value of workTitle.</p>
  
  <p><strong><a href="http://abc.dev/visit/index?artwork=workTitle" rel="nofollow noreferrer">http://abc.dev/visit/index?artwork=workTitle</a></strong></p>
  
Tags: <templating><redirect>
Title: how can pass a variable in redirect?
ThreadText: # how can pass a variable in redirect?
  
  (Asked by: username_0 on 2017-04-10)
  
  ```
  1.{% set workTitle = craft.request.getLastSegment()  %}
  2.{% if currentUser %}
  3.     {{workTitle}}
  4.{% else %}
  5.  {% redirect "/visit/index?artwork=workTitle" %}
  6.{% endif %}
  
  ```
  
  Each line of code are working fine except the line 5. I set a value on line 1. Line 3 returns the set value but on line 5 when am trying to redirect it doesn't return correct path.
  Redirect returns the below path instead of the returning the set value of workTitle.
  
  **<http://abc.dev/visit/index?artwork=workTitle>**
  
  **Tags:** templating, redirect
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-04-10. Score: 6 | Accepted answer
  
  I think:
  
  ```
  {% redirect "/visit/index?artwork="~workTitle %}
  
  ```
  
  > **Comments:**
  > **username_1**: Beat me to it  
  > **username_3**: Apparently not. @username_1 I think you had me by 3-4 seconds. Might want to add the initial "{" to your code.  
  > **username_3**: And you took the time to explain what you were doing, mine was a limp "I think". Sad.  
  
  ---
  
  ### Answer by username_1 on 2017-04-10. Score: 5
  
  Update line 5 to **concatenate** the path/URL with the variable **workTitle**.
  
  `{% redirect "/visit/index?artwork=" ~ workTitle %}`
  
  > **Comments:**
  > **username_2**: FWIW: You can also interpolate the variable, like this: `{% redirect "/visit/index?artwork=#{workTitle}" %}`. This syntax might be preferable if you have many variables to include in the query params.  
  > **username_2**: Also… the `url` Twig helper might come in handy! `{% redirect url('/visit/index', { artwork: workTitle }) %}`. The added benefit here is that it discards null values, and keeps your URLs nice and trim.  
  
  ---
  
  