My Querystring Argument Neurosis

By Deane Barker • Posted on March 19, 2005

I have a serious Web development neurosis: I hate querystring arguments. You know the garbage after the page name in a URL? Like this:

page.php?thisArgument=thisValue&andThisArgument=thisValue

I hate them. I think they’re ugly, unweidly, and expose too much of your application to the world. This is an utterly irrational thing, I know, because querystring arguments work perfectly well. I just need to get over myself.

But is the querystring argument falling out of fashion? A lot of apps now run all requests through a single page, and they grab and parse the URL themselves. For instance:

/products/hunting_gear/1

This would show page 1 of products in the hunting gear category. There is no “products” or “hunting_gear” folder or file named simply “1.” Instead, this URL is mapped to an actual block of code. You can do this with a RewriteRule pretty easily (you could do it with a PHP auto-prepend file too).

In my PHP apps, I use an AliasMatch rule to route everything to a single page and I have a mapper like this:

/product/[0-9]+/edit = edit_product.php

This uses a regular expression to map a URL pattern to a file. If the first “directory” is “product,” the second is a number of some kind, and the third is “edit,” then send them to the page to edit a product. That page will grab the number out of the URL and use it to load an object.

J2EE does this too, to map URL strings to servlets (I forget what the file is called..."web.config,” maybe?). I have no doubt that .Net has the same functionality in there somewhere. I think Rails does this too, from what Joe tells me.

Using the AcceptPathInfo directive for Apache, you can do things like this:

index.php/this/is/some/extra/info

But that just looks sloppy to me. I don’t know why. eZ publish does this by default, and it bugs me to no end.

Finally, today I found this, and it’s what prompted me to write this little diatribe:

/messages.cfm/forumid:4/threadid:39092

So they’re using AcceptPathInfo, but each “directory stop” along the way is a key-value pair. I like this. It speaks to the aesthetic in me, or to the neurotic, depending on how you look at it.

This last example perhaps proves that it’s just the syntax I don’t like – all those &'s and ='s floating around are like fingernails on a blackboard to me. This example is key-value just like traditional querystring arguments, so the function is the same, just the syntax is different. The colon-slash syntax just looks cleaner to me.

Am I the only one with this problem? Does anyone else hate querystring arguments as much as me?

This is item #294 in a sequence of 353 items.

You can use your left/right arrow keys or swipe left/right to navigate