Squeaky Clean URLs
Brad asks,
can URLs
be too clean?
Specifically, he looks at two different styles of search URLs:
- Form A
example.com/search?q=foo+bar
- Form B
example.com/search/foo+bar
I suspect people are drawn toward form B because they want "search results for 'foo bar'" to unambiguously be a resource on the web. They don’t want to have one, generic "search" resource which takes on many different forms depending on whatever parameters are passed in.
Such a (perfectly admirable and reasonable) desire stems from a misunderstanding of what the query component of a URL actually is. Consider the definition of the query component in RFC 3986 (emphasis mine):
The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource within the scope of the URI’s scheme and naming authority (if any).
So I think form A addresses the concern which appears to motivate form B.
Relatedly, here's a nice post from Mike Schinkel on how well-designed URLs are beautiful.