Answers.Body: <p>Since you use the routes.php, I think you will not need any custom route in the control panel. On the other side, you'll need something stronger to avoid (as Olivier Bon said) catching anything before your teamID. </p>
  
  <p><strong>Solution 1</strong></p>
  
  <p>Use a Single, then no user will be able to change your page slug</p>
  
  <p><strong>Solution 2</strong></p>
  
  <p>If you want to keep it that way, add a rule in your template to look if the  param matches your target page (but the solution 1 is still better).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T09:49:00.080Z
Answers.Text: Solution 1 - i would rather avoid singles unless necessary and using them just to have a route in my opinion is not good. They are good for the home page but not for a standard page in my opinion. Also, I dont want to prevent the user changing the slug. If their SEO expert tells them to then fine, you should not stop slug renaming just because the system cant then link it to a template. Solution 2 - I dont get this one... the page says it cant find the template because I have not route for it, due to adding in a second segment.
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T09:50:52.800Z
Answers.Text: I was using routes in the admin because I dont know how to add a wildcard in routes.php. And I see no other way than the system looking at every page to match the route to teamid, for any slug name. So the page mydomain.com/whateveryouwant/teamid can then be used.
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T14:16:51.297Z
Answers.Text: [1/2]
  Single are for any page that you want to be like you want (no slug change, no delete, etc.) – We use it to create flexible archive page (ex: a blog page that you want to control, from the CP, any settings like "entry per page").
  
  As for your issue, there's no wildcard in the routes.php becauce any `<param>` can be - if no validation is present - anything. But you'll need to be more specific if you dont want all second level page to matched your rule.
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T14:18:54.053Z
Answers.Text: [2/2]
  
  More specific like that :
  
  ```
  '<entrySlug:{slug}>/<teamid:\d{6}>' => ['template' => 'pages/index'],
  ```
  
  This way, the rule will match ony if the first level is an craft element and if the second level is a 6 digits (replace the `6` by your own teamid length).
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T11:19:30.310Z
Answers.Text: But you can add a wildcard * in the Routes in Admin, so the system interprets that somehow, so I assumed in routes.php there must be something to do the same. I also dont like using singles for what should be a standard page on the site. Yes for a blog listing, or home page, fine, but an About Us page or something that uses the same fields and templates as all other pages I dont like it. I also build the backend to be as easy as possible for customers to manage, and so I try to keep all pages in Pages. I also dont want to stop them changing the slug... they may want to changeit for SEO reasons
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T11:20:53.403Z
Answers.Text: OR they may want to add the contact form field we created on other pages, and its the contact form that takes the teamid to email the correct person. So we need the system to be able to pick up the teamid on any page just in case. I have not tried using ?teamid=xx because I wanted to find a cleaner way to do it, but if thats the only way, then I will have to use GET variables.
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T15:58:03.510Z
Answers.Text: My [2/2] comment was about keeping your method. The `<entrySlug:{slug}>` part will act as a wildcard, but it will ensure that the first segment is a real/existing slug in your site - and the `<teamid:\d{6}>` part (with your own digit length to replace the `6`) will target what is a valid teamid for your contact system - in the case that all teamid have the same length,
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-26T14:07:59.687Z
Answers.LastActivityDate: 2019-01-26T14:07:59.687Z
Answers.UserDisplayName: Maxime Lafrenière
Answers.Body: <p>I don't know if it's great practice to do this but if you want a "wildcard", especially as your first segment, you should a) put it in your <code>routes.php</code> manually b) make it the <strong>last route</strong> (always) otherwise it will take precedence just as you said and the other routes won't work. Also, using regex in your named parameters is good practice, if you are sure that <code>teamid&gt;</code> is always and only a number, you could do this <code>&lt;teamid:\d+&gt;</code> so that someone visiting <code>contact-us/peanuts</code> would get a 404.</p>
  
  <p>As far as setting this catch all route you want, just use a named parameter again:</p>
  
  <pre><code>'&lt;anything&gt;/&lt;teamid:\d+&gt;'         =&gt; ['template' =&gt; 'pages/index'],
  </code></pre>
  
  <p>This would have your catch all effect and will allow you to fetch the first segment if you need to. </p>
  
  <p>If you expect a certain format for this first segment, in your template by calling <code>{{ anything }}</code> you could do some sort of validation. Also you could use regular expression to narrow the possibilities down a bit... With this as is, <code>500shoes/54896</code> would return your index page...</p>
  
  <p>Hope that helps :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T17:10:01.443Z
Answers.LastActivityDate: 2019-01-26T14:49:10.907Z
Answers.LastEditDate: 2019-01-26T14:49:10.907Z
Answers.UserDisplayName: Oli
Body: <p>Not sure of this is intentional or a bug but, when we add a route using Settings -> Routes in the CMS, routes.php does not work. I guess maybe its due to us using a wildcard and this takes presedence over routes.php</p>
  
  <p>The route we needed to add in the CMS was:</p>
  
  <pre><code>*/&lt;teamid&gt;
  </code></pre>
  
  <p>The reason we need a wildcard is because I don't want to hard code the page slug as this could be changed by a website administrator which would break functionality. </p>
  
  <p>I added it in the CMS Routes because I can't find out how to add a wildcard in routes.php (perhaps worthy of another question as I would like that answer too!). </p>
  
  <p>in the meantime I have to use routes.php and hard code the slug URLs as follows for each locale:</p>
  
  <pre><code>'contact-us/&lt;teamid&gt;'         =&gt; ['template' =&gt; 'pages/index'],
  'cysylltu-â-ni/&lt;teamid&gt;'         =&gt; ['template' =&gt; 'pages/index'],
  </code></pre>
  
  <p>It would be great if I could either:
  1) Use the CMS routes with this wildcard AND routes.php still works for all my others, or 
  2) Add a wildcard in routes.php (my preference)</p>
  
  <p>Thanks</p>
  
Tags: <routes>
Title: When using Settings -> Routes in the CMS with wildcard, routes.php does not work
ThreadText: # When using Settings -> Routes in the CMS with wildcard, routes.php does not work
  
  (Asked by: username_0 on 2019-01-25)
  
  Not sure of this is intentional or a bug but, when we add a route using Settings -> Routes in the CMS, routes.php does not work. I guess maybe its due to us using a wildcard and this takes presedence over routes.php
  
  The route we needed to add in the CMS was:
  
  ```
  */<teamid>
  
  ```
  
  The reason we need a wildcard is because I don't want to hard code the page slug as this could be changed by a website administrator which would break functionality.
  
  I added it in the CMS Routes because I can't find out how to add a wildcard in routes.php (perhaps worthy of another question as I would like that answer too!).
  
  in the meantime I have to use routes.php and hard code the slug URLs as follows for each locale:
  
  ```
  'contact-us/<teamid>'         => ['template' => 'pages/index'],
  'cysylltu-â-ni/<teamid>'         => ['template' => 'pages/index'],
  
  ```
  
  It would be great if I could either:
  1) Use the CMS routes with this wildcard AND routes.php still works for all my others, or
  2) Add a wildcard in routes.php (my preference)
  
  Thanks
  
  **Tags:** routes
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-01-26. Score: 1
  
  Since you use the routes.php, I think you will not need any custom route in the control panel. On the other side, you'll need something stronger to avoid (as Olivier Bon said) catching anything before your teamID.
  
  **Solution 1**
  
  Use a Single, then no user will be able to change your page slug
  
  **Solution 2**
  
  If you want to keep it that way, add a rule in your template to look if the param matches your target page (but the solution 1 is still better).
  
  > **Comments:**
  > **username_0**: Solution 1 - i would rather avoid singles unless necessary and using them just to have a route in my opinion is not good. They are good for the home page but not for a standard page in my opinion. Also, I dont want to prevent the user changing the slug. If their SEO expert tells them to then fine, you should not stop slug renaming just because the system cant then link it to a template. Solution 2 - I dont get this one... the page says it cant find the template because I have not route for it, due to adding in a second segment.  
  > **username_0**: I was using routes in the admin because I dont know how to add a wildcard in routes.php. And I see no other way than the system looking at every page to match the route to teamid, for any slug name. So the page mydomain.com/whateveryouwant/teamid can then be used.  
  > **username_1**: [1/2] Single are for any page that you want to be like you want (no slug change, no delete, etc.) – We use it to create flexible archive page (ex: a blog page that you want to control, from the CP, any settings like "entry per page").  As for your issue, there's no wildcard in the routes.php becauce any `<param>` can be - if no validation is present - anything. But you'll need to be more specific if you dont want all second level page to matched your rule.  
  > **username_1**: [2/2]  More specific like that :  ``` '<entrySlug:{slug}>/<teamid:\d{6}>' => ['template' => 'pages/index'], ```  This way, the rule will match ony if the first level is an craft element and if the second level is a 6 digits (replace the `6` by your own teamid length).  
  > **username_0**: But you can add a wildcard * in the Routes in Admin, so the system interprets that somehow, so I assumed in routes.php there must be something to do the same. I also dont like using singles for what should be a standard page on the site. Yes for a blog listing, or home page, fine, but an About Us page or something that uses the same fields and templates as all other pages I dont like it. I also build the backend to be as easy as possible for customers to manage, and so I try to keep all pages in Pages. I also dont want to stop them changing the slug... they may want to changeit for SEO reasons  
  > **username_0**: OR they may want to add the contact form field we created on other pages, and its the contact form that takes the teamid to email the correct person. So we need the system to be able to pick up the teamid on any page just in case. I have not tried using ?teamid=xx because I wanted to find a cleaner way to do it, but if thats the only way, then I will have to use GET variables.  
  > **username_1**: My [2/2] comment was about keeping your method. The `<entrySlug:{slug}>` part will act as a wildcard, but it will ensure that the first segment is a real/existing slug in your site - and the `<teamid:\d{6}>` part (with your own digit length to replace the `6`) will target what is a valid teamid for your contact system - in the case that all teamid have the same length,  
  
  ---
  
  ### Answer by username_2 on 2019-01-25. Score: 1
  
  I don't know if it's great practice to do this but if you want a "wildcard", especially as your first segment, you should a) put it in your `routes.php` manually b) make it the **last route** (always) otherwise it will take precedence just as you said and the other routes won't work. Also, using regex in your named parameters is good practice, if you are sure that `teamid>` is always and only a number, you could do this `<teamid:\d+>` so that someone visiting `contact-us/peanuts` would get a 404.
  
  As far as setting this catch all route you want, just use a named parameter again:
  
  ```
  '<anything>/<teamid:\d+>'         => ['template' => 'pages/index'],
  
  ```
  
  This would have your catch all effect and will allow you to fetch the first segment if you need to.
  
  If you expect a certain format for this first segment, in your template by calling `{{ anything }}` you could do some sort of validation. Also you could use regular expression to narrow the possibilities down a bit... With this as is, `500shoes/54896` would return your index page...
  
  Hope that helps :)
  
  
  ---
  
  