Open In App

Describe the various components of URL

Last Updated : 15 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see the various components of the URL & will understand the purpose & meaning of each component.

URL (Uniform Resource Locator) is a technique that is utilized by browsers to get the resources that are published on the web. It provides a way to identify the exact address of the requested webpage on WWW, as it points to a unique resource. It is usually entered in the address bar of a web browser. It helps users to identify the site and its purpose too. It is vital for any website as it plays a crucial role in Search engine optimization (SEO). The components of a simple URL of any website consist of a subdomain, domain, and top-level domain like www.geeksforgeeks.org, but complex URLs consist of other components as well. such as protocol/scheme, subdomain, domain, and top-level domain, port number, file path, query-string/parameter, fragment.

We can understand the URL as the residential address in which the scheme represents the postal address that we want to use, the authority or domain name represents the city, a port represents the zip code of the area, the file path or path to the resource represents the building or area where the resource is to be delivered, the parameter denotes the extra details in the address ie., apartment or building number, & the anchor or fragment represents the person or to whom the resources to be delivered.

We will understand these components in detail, along with seeing their usage. Here, we have taken a dummy URL to understand all the possible components.

Components of the URL:

The various components of the URL are shown below:

Various components of URL

Protocol or Scheme:

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

It is a method used to access resources on the Internet. HTTP, HTTPS, FTP  are some commonly used protocols. The webpages are accessed using the HTTP protocol. HTTP stands for HyperText Transfer Protocol and HTTPS stands for HyperText Transfer Protocol Secure that makes the browser display webpages in HTML (HyperText Markup Language) format and also uses Secure Sockets Layer for encrypting data between end-user and server.

Domain name:

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

  • It consists of a subdomain (https://www.) that refers to the content type delivered to the client on the Internet like www specifies the web resource, write specifies the resource type as write.
  • The next part is a domain (https://www.geeksforgeeks.) which is the unique reference for the computer on the Internet that you are connecting to.
  • Top-level Domain (https://www.geeksforgeeks.com) refers to the domain to which the website is registered. The .com part stands for commercial and is one of the various available extensions for Top Level Domains. The others include .gov for government, .edu for an educational institution, .org for organization, etc. Every computer on the Internet has a unique IP address which is difficult to remember by the user. Since the Internet uses IP addresses, therefore, Domain names are translated into IP addresses for identifying servers.

The separator between the scheme & the domain name is :// & this colon(:) is used to separate the next part of the URL with the Scheme. The double backslash (//) represents the next part of the URL ie., the domain name.

Port number:

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

This represents the technical gate that can be utilized to access the resources on the webserver. It is an optional component specification. It is followed by a colon in the URL. The services are provided to the clients by the server using numbered ports. The default port number 80 is used by the webserver in HTTP and 443 for HTTPS. For email servers, the default port number is 25.

File path:

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

It may contain a directory, subdirectory, and file to be fetched by the user on the webserver. In this example, the path consists of the Media Library, in the content tree, folder selection to be made that you want to upload your media file to. If the filename is not specified then the web server will deliver the default webpage with extension .html like index.html. The extension asp (Active Server Pages) can also be expected for default web pages. The name of the default file relies on your server settings. Some servers use the file name default.html instead of index.html. If your site uses server-side programming to generate pages, the file will be named index.php or index.asp. Some servers display the contents of the directory if the default file is not found. Make sure you have the default files so that the directory is not visible to the third party in your browser.

Query:

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

This component consists of a question mark followed by parameters, as shown.

  • Query Separator(?): It indicates the browser regarding the specific query.
  • Parameters (rtc=1&rtn=2): Query parameters are preceded by the query string. This component is represented via key/value pairs like rtc=1, as shown in the example. Multiple parameters rtc=1&rtn=2 are separated with & symbol, to differentiate between the parameters.

Fragment: 

https://www.geeksforgeeks.org:443/media/file/upload?rtc=1&rtn=2#universal

This is an optional specification. It generally appears at the end and is preceded by the # symbol. It is an internal page reference that refers to a section within the page. The anchor can think of, the bookmark inside the resources, for the browser, which gives the direction to display the content is placed at the bookmark spot. The browser always looks for an anchor tag with a name attribute in an HTML document that matches with the fragment. 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads