8

The URL format of Stack Overflow is of the form .../id/question-title

If I add some more text at the end of the url like .../id/question-title-pink-unicorn and hit enter, the page is refreshed and the url is stripped of the pink unicorn I have just added. So far so good.

Then I change the url to .../id/question-title/persistent-pink-unicorn and hit enter, the page is refreshed and my pink unicorn is now a part of the url.

Edit: This doesn't look like a question so here is the question: Will you allow my pink unicorn to reside on the site urls or this is something that should be fixed?

3

1 Answer 1

11

The last part is just a URL slug. It makes the URL readable, instead of being just a post ID. The system just discards it, while we humans are able to glean some information about the link without having to open a new page. A similar thing happens with user profile pages.

The slash is probably not getting removed since when the system is overwriting the URL, it expects the discrepancy to have come from a post rename. Slashes are stripped when generating the slug (example), so it wouldn't expect a slash to be there at all. The script is probably split()ing the URL by slashes, and fixing only element [3]. No biggie(besides, the stuff after the slash can be used to link to an answer--I think).

Don't worry, your unicorns are safe with us.

2
  • 2
    We're actually just using MVC route binding here, you can check out our open source RouteAttribute (which we should update, it's gotten more love). If the title doesn't match what's in the DB, we redirect...pretty simple stuff on our side. Commented Nov 16, 2012 at 10:53
  • As for linking to an answer, yes: meta.stackexchange.com/questions/3122/formatting-sandbox/… This includes a #123597 hash to scroll the the linked answer, but also includes the answer's id at the end of the URL as /123597, to ensure the correct page is shown when there are many answers. (In this example, I explicitly added a sorting order in the URL as well; without that the results depend on the last sorting order one used.)
    – Arjan
    Commented Nov 17, 2012 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .