tags:

views:

49

answers:

3

If I have search that has a lot of different options, then url becomes very long and looks very bad. Is there anyway to make urls look better? Using POST to make search would keep urls clean, but people couldn't share search urls.

+1  A: 

Try doing an advanced search with many options on Google: the URL is long and not especially human-readable. I really don't think that's a problem; I don't think many people read URLs often. If you expect people to share search results, then show a button on the search results page that will generate a tinyURL-style shortened URL for that particular query.

A POST is meant for something that changes server state (e.g. a database update) and really shouldn't be used for a search.

JacobM
The point about POST being used for state changes is very valid (if a little dogmatic). Why not save options/state in a cookie. That's what they're there for!
Hober
POST also creates a terrible user experience for things like search (GET); the one downside to the cookie option is when you want to email the search to someone else?
house9
I agree that usually you shouldnt use POST to do serach, but if you consider saving search as bean to session, then that is changing state on server, but of course it something you should avoid...
newbie
While general user options, such as locale or preferred background color are totally appropriate in a cookie, the example of search options don't seem to me to be the same kind of thing; I wouldn't put them in a cookie.
JacobM
A: 

Do the different options actually need to be in the URL? For example, a quick search from my Firefox search window gives a URL like:

http://www.google.com/search?q=search&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

If I'm sending the link to anyone, I habitually cut off everything after q=search. Why not have the URL be the bare minimum that you need to send the link to someone (or bookmark), and make the rest as invisible POST variables?

Hober
Sure, but if there are options such as what language to return, how many items to show per page, what file types to search for, what dates to search for, etc. (that is, options that will actually affect what search results are returned) that will still result in a long URL.
JacobM
A: 

You can encode all of your search criteria into something like a hash and then have a single parameter in your querystring that has that value:

http://www.mysearch.com/query=2esd32d2csg3fasfdlkjSDDFdskjsEWFsDFFR39fdf

I'm not sure exactly how you'd encode everything, but it wouldn't be too difficult.

rwmnau