Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the url parameters naming convention or standards to follow

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.

like image 817
Dinesh Manne Avatar asked Feb 20 '09 09:02

Dinesh Manne


People also ask

What are the parameters used in the URL?

What Are URL Parameters? Also known by the aliases of query strings or URL variables, parameters are the portion of a URL that follows a question mark. They are comprised of a key and a value pair, separated by an equal sign. Multiple parameters can be added to a single page by using an ampersand.

What is URL naming convention?

Always use a hyphen (-) to separate keywords in a URL. Avoid other separators, such as an underscore, a plus sign or combination of other special characters. Use as few words as possible in the URL. After four or five words, search engines won't consider the rest of the words for evaluation.

How many parameters does a URL have?

1000 parameters is the maximum by default. This default can be customized in the HTTP Protocol Validation Policy. An attacker would use exceptionally long parameter names or values for three different purposes: To launch an overflow attack against the data structure that stores the parameters as name-value pairs.

Which parameters appear to the right of the in a URL?

While the query parameters appear on the right side of the '? ' in the URL, path parameters come before the question mark sign. Secondly, the query parameters are used to sort/filter resources. On the other hand, path parameters are used to identify a specific resource or resources.


2 Answers

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.

like image 193
David Grant Avatar answered Sep 22 '22 12:09

David Grant


There are no standards that I'm aware of. Just be mindful of IE's URL length limit of 2,083 characters.

like image 43
John Topley Avatar answered Sep 25 '22 12:09

John Topley