Answers.Body: <p>Setup a dynamic route that points to the same template that you have set up in the section settings for your "slug URLs". Use a pattern like so: <code>news/&lt;id&gt;</code>, which passes the 2rd URL segment as a variable named <code>id</code> to the template.</p>
  
  <p>Add this snippet to the top of your template.</p>
  
  <pre><code>{% if not entry and id %}
      {% set entry = craft.entries.id(id).first() %}
  {% endif %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
  <p>If Craft finds a route for your entry slug (<a href="https://craftcms.com/docs/routing" rel="nofollow noreferrer">routing case 3</a>), that code does nothing at all, because the entry model is already set.</p>
  
  <p>When no route was found that matches an entry slug, your dynamic route comes into play (<a href="https://craftcms.com/docs/routing" rel="nofollow noreferrer">routing case 4</a>), which routes the request to the same template.
  But now there is no entry variable set and we can go ahead and try to grab it manually using the <code>id</code> variable passed in.</p>
  
  <p><strong>Update:</strong><br>
  as already mentioned in the comments, <strong>don’t forget</strong> to setup canonical meta tags to avoid duplicate content penalties.</p>
  
  <pre><code>&lt;link rel="canonical" href="{{ entry.getUrl() }}"&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-16T08:36:35.667Z
Answers.Text: Thanks carlcs! With the pattern 'news/<id>' added in cp --> routes, it gives a 404. When I add `'newsid/(?P<id>\d{3})' => 'news/_entry'` it works fine for 3-digits id's. I'd like to accept all digits, but when removing \d{3} this route gives a 404 again.
Answers.UserDisplayName: Mark Olijslagers
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-16T08:45:53.770Z
Answers.Text: Ahh… that <id> syntax wasn’t meant to be actual code, sorry. I thought there was a draggable ID token available in the UI. I never actually use that interface and setup my routes with the craft/config/routes.php file. Where I would use the following: `'news/(?P<id>\d+)' => 'news/_entry'`.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-16T00:38:03.037Z
Answers.LastActivityDate: 2017-03-16T00:48:48.093Z
Answers.LastEditDate: 2017-03-16T00:48:48.093Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>I'm not seeing how this could be done through routes.</p>
  
  <p>Maybe you could do it with a custom plugin that listened to the <a href="https://craftcms.com/docs/plugins/hooks-reference#getElementRoute" rel="nofollow noreferrer">getElementRoute</a> hook, though.</p>
  
  <p>There is a feature request here you might want to thumb-up/comment on that would seem to do what you're looking for: <a href="https://github.com/craftcms/cms/issues/1189" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/1189</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-15T22:27:20.953Z
Answers.LastActivityDate: 2017-03-15T22:27:20.953Z
Answers.UserDisplayName: Brad Bell
Body: <p>For news entries I want both URL's www.example.com/news/678 (where 678 stands for the entry id) and www.example.com/news/some-slug to load the same entry.</p>
  
  <p>www.example.com/news/some-slug works fine because 'Entry URL Format' is used for this so the news entry contains a readable slug for SEO.</p>
  
  <p>Is there a way to generate www.example.com/news/678 (with entry id) for the same entry, to display the same news entry? Is it possible to handle this with Dynamic Routing? Or generate multiple URL Formats?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-15T20:17:12.830Z
Comments.Text: You probably don't want to do this. Duplicate content will give you a SEO penalization.
Comments.UserDisplayName: AbbeyDesign
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-15T20:27:57.807Z
Comments.Text: I need the url's with entry id for external usage. No problem to change to www.example.com/**some-other-text**/678 for example and disallow it in robots.txt to prevent a SEO penalty.
Comments.UserDisplayName: Mark Olijslagers
Tags: <entry><url><routing><format>
Title: Multiple URL's for news entry?
ThreadText: # Multiple URL's for news entry?
  
  (Asked by: username_0 on 2017-03-15)
  
  For news entries I want both URL's www.example.com/news/678 (where 678 stands for the entry id) and www.example.com/news/some-slug to load the same entry.
  
  www.example.com/news/some-slug works fine because 'Entry URL Format' is used for this so the news entry contains a readable slug for SEO.
  
  Is there a way to generate www.example.com/news/678 (with entry id) for the same entry, to display the same news entry? Is it possible to handle this with Dynamic Routing? Or generate multiple URL Formats?
  
  **Tags:** entry, url, routing, format
  
  > **Comments:**
  > **username_1**: You probably don't want to do this. Duplicate content will give you a SEO penalization.  
  > **username_0**: I need the url's with entry id for external usage. No problem to change to www.example.com/**some-other-text**/678 for example and disallow it in robots.txt to prevent a SEO penalty.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-03-16. Score: 2 | Accepted answer
  
  Setup a dynamic route that points to the same template that you have set up in the section settings for your "slug URLs". Use a pattern like so: `news/<id>`, which passes the 2rd URL segment as a variable named `id` to the template.
  
  Add this snippet to the top of your template.
  
  ```
  {% if not entry and id %}
      {% set entry = craft.entries.id(id).first() %}
  {% endif %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  If Craft finds a route for your entry slug ([routing case 3](https://craftcms.com/docs/routing)), that code does nothing at all, because the entry model is already set.
  
  When no route was found that matches an entry slug, your dynamic route comes into play ([routing case 4](https://craftcms.com/docs/routing)), which routes the request to the same template.
  But now there is no entry variable set and we can go ahead and try to grab it manually using the `id` variable passed in.
  
  **Update:**  
  as already mentioned in the comments, **don’t forget** to setup canonical meta tags to avoid duplicate content penalties.
  
  ```
  <link rel="canonical" href="{{ entry.getUrl() }}">
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_2! With the pattern 'news/<id>' added in cp --> routes, it gives a 404. When I add `'newsid/(?P<id>\d{3})' => 'news/_entry'` it works fine for 3-digits id's. I'd like to accept all digits, but when removing \d{3} this route gives a 404 again.  
  > **username_2**: Ahh… that <id> syntax wasn’t meant to be actual code, sorry. I thought there was a draggable ID token available in the UI. I never actually use that interface and setup my routes with the craft/config/routes.php file. Where I would use the following: `'news/(?P<id>\d+)' => 'news/_entry'`.  
  
  ---
  
  ### Answer by username_3 on 2017-03-15. Score: 0
  
  I'm not seeing how this could be done through routes.
  
  Maybe you could do it with a custom plugin that listened to the [getElementRoute](https://craftcms.com/docs/plugins/hooks-reference#getElementRoute) hook, though.
  
  There is a feature request here you might want to thumb-up/comment on that would seem to do what you're looking for: <https://github.com/craftcms/cms/issues/1189>
  
  
  ---
  
  