# Slugs that start with numbers parsed as IDs

**URL:** https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258
**Category:** Feature
**Created:** [9월 16, 2016, 10:06오후 UTC](https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258 "2016-09-16T22:06:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [9월 16, 2016, 10:06오후 UTC](https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258/1 "2016-09-16T22:06:49Z")

</div>

`http://site/some-slug` gets redirected to [http://site/some-slug/ID](http://site/some-slug/ID). That’s awesome.

But, `http://site/21st-some-slug` gets redirected to `http://site/whatever-slug-it-is-for-id/21`.

Is there a way to fix this? I’m poking around in `routes.rb`, thinking I could find a regex to change, but that doesn’t’ seem like the way.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9월 16, 2016, 10:13오후 UTC](https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258/2 "2016-09-16T22:13:27Z")

</div>

Interesting, any ideas here @eviltrout? Probably a Rails routing thing.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [9월 19, 2016, 5:32오후 UTC](https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258/3 "2016-09-19T17:32:30Z")

</div>

That was trickier than I expected it to be, since it only fails when the topic whose id matches the same number exists. Here’s a fix:

[https://github.com/discourse/discourse/commit/2766b2edc3fc68803d254d9039ca044e25a56d2e](https://github.com/discourse/discourse/commit/2766b2edc3fc68803d254d9039ca044e25a56d2e)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [9월 19, 2016, 5:32오후 UTC](https://meta.discourse.org/t/slugs-that-start-with-numbers-parsed-as-ids/50258/4 "2016-09-19T17:32:33Z")

</div>


