tags:

views:

133

answers:

8
A: 

Search engines like text in URLs.

Pages are given higher rank when the search terms actually appear in the URL rather than just the page. It's robot sugar, basically.

snicker
+1  A: 

It allows the URL to contain some interesting information for humans and search engines, but still works even if the title changes.

You could store the original "slug" in the database and verify against that as well as the id, but the only thing it prevents is games like this:

http://stackoverflow.com/questions/1534161/you-could-have-worked-that-out

:)

Paul Dixon
A: 

This allows you to see in the url some text which means something to you. If I look in a history of links a bunch of questions, the number alone would be meaningless. However, having the text there allows me to have some context.

Anthony Potts
A: 

This is SEO (search engine optimization) in action. It helps with the ranking of pages in search results (on google, yahoo, bing, ...), because search engines give higher rankings to pages which URL's contain keywords the user is searching for.

Jan Hančič
+3  A: 

Part of the reason is so you can change your user name or the title of the post (correcting spellings etc.) but leave the URL valid.

It makes SEO sense to have the title in the URL - it makes it a lot more likely that the site will get indexed correctly.

ChrisF
+1 for changes to titles being important.
ceejayoz
A: 

Theoretically, it's for SEO reasons. The software ignores the part following the identifier (the "slug"), but the idea is that search engine crawlers consider the description part of the link text, and thus weigh the resulting page higher in search results. Whether this actually happens in any meaningful way, I don't know for sure.

A more practical use is that you can gain a better idea of where a link's pointing just by inspecting the slug, which is handy if you've got multiple question URLs.

Rob
A: 

In addition to the benefit for Search Engines (the text in the URL is powerful), the fact is for all practical purposes this URL does not "change". A change can be defined as something which causes a link at some point in the future not to work - this would never be the case with this URL. The varying text at the end does not affect any user's ability to access the underlying resource.

aronchick
A: 

"cool URIs do not change"

Cool URIs can change, as long as the old ones are still fine.

Maybe someone will decide that “Lack of invariance in stackoverflow URL. Why ?” is a bad question title, and change it to “Why is there redundant information in SO URLs?”. It would be good if the slug can update to reflect the new title, especially if the reason we wanted to change it was an embarrassing typo. But the old URI must continue to work.

One drawback to non-canonical URIs is that search engines can get confused and think they're two different pages. Or they'll spot that they're two pages the same, but decide that the ‘best’ page to link to is the one with the title you don't want. This is especially bad if lots of people link to another title completely like:

http://stackoverflow.com/questions/1534161/stackoverflow-smells-of-poo

cue more embarrassment. The best way around this (though few sites bother, and SO doesn't) is to check the slug on submission and do a 301 permanent redirect to the new URI with the up-to-date slug instead. Search engines will pick up the new URI and not any malicious one with poo in it.

bobince