What are the url parameters naming convention or standards to follow

Dinesh Manne picture Dinesh Manne · Feb 20, 2009 · Viewed 36.2k times · Source

Are there any naming conventions or standards for Url parameters to be followed. I generally use camel casing like userId or itemNumber. As I am about to start off a new project, I was searching whether there is anything for this, and could not find anything. I am not looking at this from a perspective of language or framework but more as a general web standard.

Answer

David Grant picture David Grant · Feb 20, 2009

I recommend reading Cool URI's Don't Change by Tim Berners-Lee for an insight into this question. If you're using parameters in your URI, it might be better to rewrite them to reflect what the data actually means.

So instead of having the following:

/index.jsp?isbn=1234567890
/author-details.jsp?isbn=1234567890
/related.jsp?isbn=1234567890

You'd have

/isbn/1234567890/index
/isbn/1234567890/author-details
/isbn/1234567890/related

It creates a more obvious data structure, and means that if you change the platform architecture, your URI's don't change. Without the above structure,

/index.jsp?isbn=1234567890

becomes

/index.aspx?isbn=1234567890

which means all the links on your site are now broken.

In general, you should only use query strings when the user could reasonably expect the data they're retrieving to be generated, e.g. with a search. If you're using a query string to retrieve an unchanging resource from a database, then use URL-rewriting.