The different parts of a URL
11 March 2022 (Updated 11 March 2022)
On this page
What is a URL?
A URL (Uniform Resource Locator) helps identify the address of a resource on the computer network and the method of obtaining it.
Here’s the format of a typical URL:
<scheme>://<host>:<port>/<path>?<query>#<fragment>
Here’s an example URL:
https://www.google.com/search?q=tokyo+population
The different parts of a URL
URLs consist of the following parts.
- Scheme:
(http
). The scheme describes how the resource can be obtained (i.e., via which protocol – HTTP, HTTPS, FTP, etc?). - Host: (
google.com)
The host identifies the location of the computer on the network. The format of the host will depend on the scheme. For example, if the scheme is HTTP or HTTPS, the host will usually be a domain name such as google.com that in turn points to an IP address such as142.250.65.238
. - Path:
(/search)
The path identifies the location of a resource within the host. A single host usually has many resources such as different HTML pages, images, stylesheets, JavaScript files, and so on. - Query string: (
?q=tokyo+population
) The query string is usually interpreted, if at all, by the application on the server. In the above example, the Google search engine is programmed to interpretq=tokyo+population
to mean the user is requesting search results for the termtokyo population
. - Port: this describes the port at which the host is listening for incoming HTTP requests. This is usually either 80 (HTTP) or 443 (HTTPS) in which case you can omit them when using most browsers or client libraries.
- Fragment: the fragment is the part after the hash sign ( e.g.,
https://sajadtorkamani.com/posts/#mysql
) and is used to focus a web page on a particular HTML element using its ID.
Tagged:
HTTP
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment