newbie
newbie

Reputation: 24635

How can I make clean search urls?

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.

Upvotes: 0

Views: 176

Answers (3)

SqlRyan
SqlRyan

Reputation: 33914

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.

Upvotes: 0

bsberry
bsberry

Reputation: 1008

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?

Upvotes: 0

Jacob Mattison
Jacob Mattison

Reputation: 51052

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.

Upvotes: 1

Related Questions