0

I noticed today that SO uses magic URLs in the form. For example, a question is ".../questions/[nnn]/[description]. As an experiment when showing a question I changed the description and hit enter. As expected, it did not affect the request and the question showed just fine, only with a garbage URL:

http://stackoverflow.com/questions/1933822/flksdjfkljlfs

I assume, but could be wrong, that this reflects a RESTful approach to URLs. Since I am in the process of build a new web app, I was wondering, why is this better than than some of the more "traditional" alternatives?

http://stackoverflow.com/questions/1933822
http://stackoverflow.com/questions?Question=1933822

It seems wrong to me, for reasons I can't define, to have a URL with completely redundant and ignored information (the question name).

Lawrence Dol
  • 63,018
  • 25
  • 139
  • 189

3 Answers3

7

It's for SEO (Search Engine Optimization) reasons. Google favors URLs that have in them the text of the search query. It's a bit cheating (that is just my personal opinion) but most websites do it, including mine* :)

The URL for this question is:

What's the advantage of URLs with semantically dead components?

Let's say you search for "urls with semantically dead components". Google uses many factors in deciding the order in which results are shown; but let's say that another site has the same exact factors but an URL like www.site.com/question/1000. Google would display stackoverflow first.


*I go a bit further and 301 (permanently redirect) the most popular search engines that crawl /url/id without /text.

This is done for both the reasons mentioned above and also to have only one valid (canonical) URL for search engines.

If you choose to include extra text in your URLs I suggest you follow the same approach since google somewhat penalizes websites with duplicate content, always have one canonical URL, at least for search engines!

Community
  • 1
  • 1
Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
2

Well with the title as part of the URL, it has meaning when read by humans, too.

Yuliy
  • 17,381
  • 6
  • 41
  • 47
1

I think SO uses a nice approach here. It's a combination of user-friendly and computer-friendly information. The service is able to efficiently locate the correct question because of the ID number, while humans can quickly get an understanding of what the web page is about just by looking at the URL before even clicking on it.

Jeff
  • 21,744
  • 6
  • 51
  • 55