My Querystring Argument Neurosis

By Deane Barker 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:


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:


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:


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:


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?

Comments (14)

Paul Prescod says:

Query strings and paths have different semantics. The path represents a hierarchy and relative URLs work their way around the hierarchy. If you have an /a/b/c then it is polite of you to have pages called /a and /a/b. Query strings have no hierarchy.

Deane says:

An excellent point.

Thomas Fruetel says:

What bugs me most about this, if I copy and paste those multi parameter links in my blog postings, it ruins XHTML validity, as ampersands need to be masked for valid HTML. I actually made myself a bookmarklet for replacing all & in an input form with &amp so I don’t have to do this manually all the time.

Deane says:

Yeah, we talked about that problem here:

Thomas Fruetel says:

Good to know I’m not the only one that is annoid by that. In case you are interested, my bookmarklet solution goes like this:

javascript:area=document.getElementById('inputbody’);area.value=area.value.replace(/&/g, ‘&');area.focus();

This works for my NucleusCMS Blog, where the text input has the ID inputbody. You might change that ID for your own forms.

Philipp Lenssen says:

I dislike them too, and it’s not just for aesthetical reasons: Google also prefers less parameters. I use htaccess to convert GET parameters, but I use the minus operator, or hide any special character: (postid=6857) (item=china)

bob says:

I do appreciate the aesthetics of this, but how does it scale?

You’re adding layers of processing on top of each page request, which will necessarily reduce the maximum you can serve per second, but how significant is the hit?

Also, does anyone know how to implement it on iis?

Deane says:

For IIS, you’d need something like ISAPI Rewrite:

Or you could rig it up using the 404 page, but that’d be a hack. I would NEVER do something like that... [rolls his eyes and hopes no one finds out about all those projects he did back in ‘99)]

sdf says:


dan says:

i agree! i need to convert my PHP to use slashes – Deane you said it’d be a hack to use the 404 page, but on IIS is there any other way? would it really be that bad – if so what’s wrong with using 404?

i’m uploading to a public server so installing any other software is a no-no.

thanks in advance, -dan

mavenaut says:

Silly question time – why not just use POST method rather than GET method

Deane says:

You can use POST from a form, but how are you going to use POST from a simple hyperlink?

dan says:

using POST is actually another question i had – would anyone know how to post direct to “” instead of “”?

the idea here is to completely hide the fact that i’m using PHP.

Is it at all possible to submit straight to the “/” and let index.php take it from there? Do i need rewrite rules for this?


John says:

This is the best tool I know for real mod_rewrite on IIS:

IIS Mod-Rewrite