简体   繁体   中英

Cleaning up URL

I installed friendly_id to clean up the model urls but I have a search function on my site and I'm not sure how to best clean that up. This is what my search url looks like:

http://localhost:3000/s?utf8=%E2%9C%93&s%5Blocation%5D=Paris%2C+France&s%5Bactivity%5D=6&s%5Bstart_time%5D=Aug+3rd+2015%2C+3%3A00+am&s%5Bend_time%5D=Aug+17th+2015%2C+4%3A00+am&s%5Bgeo%5D=%5B48.856614%2C2.3522219000000177%5D

Wondering if there's anything I can do since search isn't associated with a model so I can't use friendly_id.

"Cleaning" a search URL is definitely tricky. Search parameters can contain spaces or other characters, including slashes, that may conflict with the Rails routing or even the URI RFC specification.

That's why trying to achieve friendly URLs for search parameters is a waste of time. There is not even a real need for that.

Friendly URLs are generally useful in terms of user readability and marketing (eg SEO). None of these advantages generally applies to a search form.

A quick option could be to change the search form from using GET parameters to POST (but you will lose the ability to pass a search link to someone else).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM