A URL parameter is a method for passing data to web applications by placing variables in the URL. These parameters begin after the "?" character of some URLs, and contains the name of the parameter followed by the equals sign and its value. Each parameter is separated using the "&" character.
In the URL "http://www.example.com/view-product.php?productid=34284&sort=asc&page=2", we can see three different URL parameters:
Parameter Name - Value
productid - 34284
sort - asc
page - 2
URL parameters can serve many purposes, but generally speaking they are often used to pass data to the web application to be used to render the page. In our example above, the "view-product.php" page most likely is a template page that can dynamically display different products' details.
By passing the product ID as a URL parameter, the web application knows to retrieve this product's information from the database on display it on the page. It also knows to sort the other products on the page ascending (using the parameter "sort=asc"), and to start on page 2 ("page=2").
One of the main advantages of using URL parameters over other methods of passing data to web applications is that since all the data is saved in the URL, it's easy to bookmark or send a link to a page that was generated dynamically from the URL parameters. By using URL parameters you can easily send a link or a bookmark a specific product page, directions to a business on a mapping service, or saved search. This is not as easily done with other methods.
However, there are several drawbacks to using URL parameters as well:
- Multiple URL parameters often can create many duplicate or near-duplicate pages. Consider www.example.com/blue-widgets?sort=asc and www.example.com/blue-widgets?sort=desc – these two pages most likely have the exact same content, but arranged slightly differently on the page.
- Multiple URL parameters are not very friendly for humans to read, type, or remember. They're also prone to being overly long, which can be a usability issue.
- Often times, using URL parameters lends itself to not having keywords in the URL (Consider www.example.com/view-product.php?id=482794 vs. www.example.com/blue-widgets-chicago).
Therefore, URL parameters should be minimized or avoided when possible by using server-side URL rewrites.