当前位置: 动力学知识库 > 问答 > 编程问答 >

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.

网友答案:

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.

网友答案:

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.

网友答案:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: