Reputation: 70983
I like Stack Overflow's URLs - specifically the forms:
It's great because as the title of the question changes, the search engines will key in to the new URL but all the old URLs will still work.
Jeff mentioned in one of the podcasts - at the time the Flair feature was being announced - that he regretted some design decisions he had made when it came to these forms. Specifically, he was troubled by his pseudo-verbs, as in:
It was a bit unclear which of these verb forms he ended up preferring.
Which pattern do you prefer (1 or 2) and why?
Upvotes: 3
Views: 284
Reputation: 28386
I like number 2:
also:
/questions/foo
== All questions called "foo"
/questions/{id}/foo
== A question called "foo"
/users/aiden
== All users called aiden
/users/{id}/aiden
== A user called aiden
/users/aiden?a=edit
or /users/aiden/edit
== Edit the list of users called Aiden?
/users/{id}/edit
or /users/{id}?a=edit
is better
/rss/users/aiden
== An RSS update of users called aiden
/rss/users/{id}
== An RSS feed of a user's activity
/rss/users/{id}/aiden
== An RSS feed of Aiden's profile changes
I don't mind GET arguments personally and think that /x/y/z should refer to a mutable resource and GET/POST/PUT should act upon it.
My 2p
Upvotes: 1
Reputation: 389
I prefer the 2nd option as well.
But I still believe that the resulting URLs are ugly because there's no meaning whatsoever in there. That's why I tend to split the url creation into two parts:
/posts/42
/posts/42-goodbye-and-thanks-for-all-the-fish
Both URLs refer to the same document and given the latter only the id is used in the internal query. Thus I can offer somewhat meaningful URLs and still refrain from bloating my Queries.
Upvotes: 1
Reputation: 11460
I prefer pattern 2 for the simple reason is that the URL reads better. Compare:
If you forget the last part of each URL, then in the second URL you have a nice recovery plan.
My 2 pennies!
Upvotes: 8
Reputation: 5993
/question/how-do-i-bake-an-apple-pie /question/how-do-i-bake-an-apple-pie-2 /question/how-do-i-bake-an-apple-pie-...
Upvotes: 0
Reputation: 35117
My guess would be he preferred #2.
If you put the string first it means it always has to be there. Otherwise you get ugly looking urls like:
/users//4534905
No matter what you need the id of the user so this
/user/4534905/
Ends up looking better. If you want fakie verbs you can add them to the end.
/user/4534905/edit
Upvotes: 2
Reputation: 21178
Neither. Putting a non-English numeric ID in the URL is hardly search engine friendly. You are best to utliize titles with spaces replaced with dashes and all lowercase. So for me the correct form is:
/question/how-do-i-bake-an-apple-pie
/user/frank-krueger
Upvotes: 1