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.
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.
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.
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.
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.
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.
There are no standards that I'm aware of. Just be mindful of IE's URL length limit of 2,083 characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With