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.

Example

In the URL "http://www.example.com/view-product.php?productid=34284&sort=asc&page=2", we can see 3 different URL parameters:

Parameter Name

Value

productid

34284

sort

asc

page

2

What are URL parameters used for

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.

Bypassing 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").

Advantages of using URL parameters

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 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.

Disadvantages of using URL parameters

However, there are several drawbacks to using URL parameters as well:

Therefore, URL parameters should be minimized or avoided when possible by using server-side URL rewrites.

Did this answer your question?