Answers.Body: <p>Routes can't include query strings. A route is a path to a template file (or a controller action, if you've written a custom plugin).</p>
  
  <p>You can retrieve a query string value from within a template using the <a href="https://craftcms.com/docs/templating/craft.request#getParam" rel="nofollow noreferrer"><code>craft.request.getParam</code> method</a>.</p>
  
  <p>For example:</p>
  
  <pre><code>{% set token = craft.request.getParam('token') %}
  </code></pre>
  
  <h2>Update</h2>
  
  <p>Following the conversation in the comments, here is an example of this working with a standard Craft route.</p>
  
  <p>My example route <code>/querystring/test</code> points to the template <code>_views/querystring-test.twig</code>, which contains the following example code.</p>
  
  <pre><code>&lt;h1&gt;Query String Test&lt;/h1&gt;
  
  {% if craft.request.getParam('example') %}
      &lt;p&gt;The query string value for &lt;code&gt;example&lt;/code&gt; is "{{ craft.request.getParam('example') }}",&lt;/p&gt;
  {% else %}
      &lt;p&gt;There is no query string parameter.&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>Here is a screenshot of the page <em>without</em> a query string:</p>
  
  <p><a href="https://i.sstatic.net/JLS2Y.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JLS2Y.png" alt="enter image description here"></a></p>
  
  <p>And here is a screenshot of the page <em>with</em> a query string:</p>
  
  <p><a href="https://i.sstatic.net/PjFZB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PjFZB.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T18:32:42.413Z
Answers.Text: I'm just trying to make sure that the template file loads even though the URL has a query parameter. I'm thinking that should be possible and that it is a rather common use case. Am I wrong?
Answers.UserDisplayName: Kristian S. Munkvold
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T19:53:49.087Z
Answers.Text: The route will match, and the template will load, regardless of whether the URL contains query parameters.
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T22:16:34.123Z
Answers.Text: I thought that would be the case, but if you have a look at the screenshots above – that's not what's going on. Any ideas of what might be wrong here?
Answers.UserDisplayName: Kristian S. Munkvold
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-25T00:20:21.813Z
Answers.Text: Have you tried appending the query string to `/test/register`, without the trailing slash?
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-26T08:21:58.943Z
Answers.Text: Yes, and I get the same result. Whenever I introduce a Query Parameter the result is "page not found" on all the routes.
Answers.UserDisplayName: Kristian S. Munkvold
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-26T10:29:04.627Z
Answers.Text: This doesn't sound like a Craft problem. I'm guessing it's an issue with your Apache or nginx configuration. I've updated my answer to include details of my working example.
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-26T10:49:16.010Z
Answers.Text: Oh. After quite some time debugging we figured out that we're using a reserved Query Parameter. It works fine with anything besides the Query Param "token". (https://craftcms.com/docs/config-settings#tokenParam)
  
  We'll do the name change. ;)
Answers.UserDisplayName: Kristian S. Munkvold
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-24T17:31:51.840Z
Answers.LastActivityDate: 2017-05-26T10:27:45.633Z
Answers.LastEditDate: 2017-05-26T10:27:45.633Z
Answers.UserDisplayName: Stephen Lewis
Body: <p>I am currently setting up routes for a one-page application. As soon as a Query Parameter is introduced, the route fails. The route "test" replaces "my-av1" in the following photos.</p>
  
  <p>The documentation in Craft does not describe how Query Parameters are handled. How do I proceed from here?</p>
  
  <p><a href="https://i.sstatic.net/k7whh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/k7whh.png" alt="Routes should work as described – but as soon a Query Parameter is introduced in the url, the route stops working."></a>
  <a href="https://i.sstatic.net/c61G1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c61G1.png" alt="The route &quot;test&quot; replaces my-av1"></a></p>
  
Tags: <control-panel><routes>
Title: How do you handle routes in CP with Query Parameters?
ThreadText: # How do you handle routes in CP with Query Parameters?
  
  (Asked by: username_0 on 2017-05-24)
  
  I am currently setting up routes for a one-page application. As soon as a Query Parameter is introduced, the route fails. The route "test" replaces "my-av1" in the following photos.
  
  The documentation in Craft does not describe how Query Parameters are handled. How do I proceed from here?
  
  [![Routes should work as described – but as soon a Query Parameter is introduced in the url, the route stops working.](https://i.sstatic.net/k7whh.png)](https://i.sstatic.net/k7whh.png)
  [![The route "test" replaces my-av1](https://i.sstatic.net/c61G1.png)](https://i.sstatic.net/c61G1.png)
  
  **Tags:** control-panel, routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-05-24. Score: 2
  
  Routes can't include query strings. A route is a path to a template file (or a controller action, if you've written a custom plugin).
  
  You can retrieve a query string value from within a template using the [`craft.request.getParam` method](https://craftcms.com/docs/templating/craft.request#getParam).
  
  For example:
  
  ```
  {% set token = craft.request.getParam('token') %}
  
  ```
  
  ## Update
  
  Following the conversation in the comments, here is an example of this working with a standard Craft route.
  
  My example route `/querystring/test` points to the template `_views/querystring-test.twig`, which contains the following example code.
  
  ```
  <h1>Query String Test</h1>
  
  {% if craft.request.getParam('example') %}
      <p>The query string value for <code>example</code> is "{{ craft.request.getParam('example') }}",</p>
  {% else %}
      <p>There is no query string parameter.</p>
  {% endif %}
  
  ```
  
  Here is a screenshot of the page *without* a query string:
  
  [![enter image description here](https://i.sstatic.net/JLS2Y.png)](https://i.sstatic.net/JLS2Y.png)
  
  And here is a screenshot of the page *with* a query string:
  
  [![enter image description here](https://i.sstatic.net/PjFZB.png)](https://i.sstatic.net/PjFZB.png)
  
  > **Comments:**
  > **username_0**: I'm just trying to make sure that the template file loads even though the URL has a query parameter. I'm thinking that should be possible and that it is a rather common use case. Am I wrong?  
  > **username_1**: The route will match, and the template will load, regardless of whether the URL contains query parameters.  
  > **username_0**: I thought that would be the case, but if you have a look at the screenshots above – that's not what's going on. Any ideas of what might be wrong here?  
  > **username_1**: Have you tried appending the query string to `/test/register`, without the trailing slash?  
  > **username_0**: Yes, and I get the same result. Whenever I introduce a Query Parameter the result is "page not found" on all the routes.  
  > **username_1**: This doesn't sound like a Craft problem. I'm guessing it's an issue with your Apache or nginx configuration. I've updated my answer to include details of my working example.  
  > **username_0**: Oh. After quite some time debugging we figured out that we're using a reserved Query Parameter. It works fine with anything besides the Query Param "token". (https://craftcms.com/docs/config-settings#tokenParam)  We'll do the name change. ;)  
  
  ---
  
  