Ugly URL after submitting form with GET

I’m using a CFormModel instance to collect user input and perform a search according to this data. I need to use the GET method in order to let my users share the URLs with others. Unfortunately, the url takes a very ugly shape after the submission. Here is how it looks;

mysite.com/?r=category%2Fview&FilterForm[colorIds][]=6&FilterForm[authorId]=&FilterForm[categoryId]=7&yt0=Search

How can we beautify this a little bit?

What methods would you use to create user friendly and SEO optimized urls in this case?

my way might be complicated but if you really use your method a lot to share your result with others, it might be worth trying:

  • create a model contains basic two fields, nice_url, ugly_url;

  • each time your submit the search, in search action you will automatically generate nice_url and save the pair of nice_url and ugly_url

  • then you share the nice_url with others, when other come back request the nice_url, this model translate nice to ugly internally.

  • you can have extra field for user to describe the search to help others visually.

i would create something if i got time

use method = post. :)

Good idea. Is there a special name for this method? I will read more about it.

not hatch yet.

idea like http://goo.gl/

i not sure if google has an api to use or create your own in yii app

You could introduce a custom urlRule rendering something like that:

www.foo.com/search/Smith-author/red-color/Biology-cat

During url parsing you can tokenize and recognize by the part after the dash.

"Smith" (search for name "Smith" on author table)

"red" (show only items with color red)

"Biology (in catgory "Biology")