Log in

No account? Create an account
Chaz Meyers [entries|archive|friends|userinfo]
Chaz Meyers

[ website | chazmeyers.com ]
[ profile | view profile ]
[ archive | view archive ]

[Links:| chazmeyers.com Twitter ]

URL prettiness to excess. [Oct. 25th, 2007|04:41 pm]
Chaz Meyers
Lately I've been using CodeIgniter. CI is a lightweight PHP framework

I know that Pretty URLs are fashionable. CI takes it to a new extreme by unsetting $_GET by default.

Why? Because you should be POSTing or using longer URLs instead. Check out their $this->uri->assoc_to_uri() example on how to "properly" handle hashy query data.

Does anyone seriously think that http://www.example.com/shoes/gender/male/size/18/color/brown is a significantly better URL than http://www.example.com/shoes?gender=male&size=18&color=brown?

Have we thrown out the idea that only one URL should point to a given resource? (I'm betting if you swap around gender and size in the above example it would have the same result and give a 200 response instead of redirecting to a permalink.)

Are GET forms no longer are acceptable for things like searches that don't have side effects? (I'm pretty sure this change completely breaks non-POST forms.)

Don't get me wrong. Pretty URLs are great, and I wouldn't blink an eye if Opinionated Software like RubyOnRails removed GET parameters by default. But in a lightweight framework like CodeIgniter? It seems a bit odd.

From: (Anonymous)
2007-10-25 10:25 pm (UTC)

That's not what pretty URLs look like.

A pretty URL using CodeIgniter results in:


If you are doing a search as I assumed you were suggesting in your post, a "pretty" url would look like:


If you noticed, I removed your three argument names (gender, size, and color). A lot simpler, shorter and cleaner.
(Reply) (Thread)
[User Picture]From: cpm
2007-10-26 11:54 am (UTC)
The http://www.example.com/shoes/show-name-here/ is a great URL for a specific shoe, yes.

But I still don't think it's a good match for searches with multiple fields. Suppose now that you're not searching for a particular size. Now your search URL looks something like /search/shoes/any/any/brown, or worse /search/shoes///brown Ordered URL parameters are fine for representing hierarchy, but for things like searches and prepopulating forms with specific values via links, named parameters can be useful.

Also, the initial form submission will still need to be a POST since GET form submissions are not possible under this scheme. So if developers want linkable searches they have to have an separate action that does nothing but receives the POST form input, translates it into proper URL, and redirects to the URL for that particular search. This is compared to just making it a GET submission and getting linkable searches for free out of the box.
(Reply) (Parent) (Thread)