What is URL (Uniform Resource Locator) ?
Last Updated :
23 Jan, 2024
A URL or Uniform Resource Locator is a Unique identifier that is contained by all the resources available on the internet. It can help to locate a particular resource due to its uniqueness. It is also known as the web address. A URL consists of different parts like protocol, domain name, etc. The users can access the URLs by simply typing them inside the address bar or by clicking any button or link web page.
URLExample URL:
https://www.geeksforgeeks.org/
Structure of a URL
A URL starts with a protocol followed by the name of the resource that has to be accessed. URL uses the protocols as the primary access medium to access the domain or subdomain specified after that wherever the resource is located. It uses multiple protocols like HTTP (Hypertext Transfer Protocol), HTTPS Protocol (Secured HTTP), mailto for emails, FTP (File Transfer Protocol) for files, and TELNET to access remote computers. Mostly the protocol names are specified using the colons and the double forward slashes, but the mailto protocol is specified using the colons only.
Optional Parts after the domain name in a URL:
- A path to a particular page or file can be specified.
- Some extra query parameters can also be specified.
- Network port to make the connection.
- Reference to a particular point in the file or a HTML element on the page.
Different Parts of a URL
A URL consists of mutliple parts that can helps you to visit a particular page on the internet. Every part of a URL has its own importance. Let us discuss about the different parts of a URL.
.webp)
Reference URL:
https://www.geeksforgeeks.org/array-data-structure/?ref=home-articlecards#what-is-array
The protocol or scheme:
A URL starts with a protocol that is used to access the resource on the internet. The resource is accessed through the Domain Name System or DNS. There are multiple protocols avaiable to use like HTTP, HTTPS, FTP, mailto, TELNET etc. The protocol used in the above URL is https.
Domain or Host Name:
It is the reference or name of the page that you are going to access on the internet. In this case, the domain name is: www.geeksforgeeks.org.
Port Name:
It is defined just after the domain name by using the colons between itself and the domain name. Generally, it is not visible in the URL. The domain name and the port name combinely can be known as Authority. The default port for web services is port80 (:80).
Path:
It refers to the path or location of a particular file or page stored on the web server to access the content of it. The path used here is: array-data-structure.
Query:
A query mainly found in the dynamic pages. It consists of a question mark(?) followed by the parameters. In above URL query is: ?.
Parameters:
These are the pieces of information inside a query string of URL. Multiple parameters can be passed to a URL by using the ampersand(&) symbol to separate them. The query parameter in above URL is: ref=home-articlecards.
Fragments:
The fragments appear at the end of a URL starts with a Hashtag(#) symbol. These are the internal page references that refers to a specific section within the page. The fragment in the above URL is: #what-is-array.
Similar Reads
What is RestFul API?
APIs play an important role in the communication between different software systems. Traditional methods of doing this were often complicated, slow, and hard to grow. RESTful APIs solve these problems by offering a simple, fast, and scalable way for systems to communicate using standard web protocol
7 min read
What is URL Locator & what are common schemes used for the URL in HTML ?
Every HTML document on the internet has a unique URL. URL stands for Uniform Resource Locator. The URL is the HTML document's address on the internet. Any file that can be accessed via the internet has a URL, including images, JavaScript files, CSS files, Flash files, and so on. To view an HTML docu
2 min read
Node.js URL.format(urlObject) API
The URL.format(urlObject) is the inbuilt API provided by URL class, which takes an object or string and return a formatted string derived from that object or string. Syntax: const url.format(urlObject) If the urlObject is not an object or string, then it will throw a TypeError. Return value: It retu
4 min read
How to specify URL of resource to be used by the object in HTML5 ?
In this article, we will cover how to specify the URL of the resource to be used by the object in HTML5. It can be used on pages where content from an external source is required. It can be done by setting the data attribute to the specified URL in the <object> tag. Syntax: <object data="UR
1 min read
Web API URL.origin Property
The Web API URL.origin property returns a USVString containing the origin of the URL. Syntax: var str = URL.origin Return Value: This property returns a USVString containing the origin of the URL. Example 1: [GFGTABS] HTML <!DOCTYPE html> <html> <body> <h1>GeeksforGeeks</h
1 min read
Web API URL.pathname Property
The Web API URL.pathname property is used to get USVString containing an initial â/â followed by the path of the URL. Syntax: var str = URL.pathname Return Value: This property returns a USVString containing the pathname of the URL. Note: If there is no path set for the URL, so it will Return only /
1 min read
Web API URL.protocol Property
The Web API URL.protocol property is used to get USVString containing the protocol scheme of the URL. Syntax: var str = URL.protocol Return Value: This property returns a USVString containing the protocol scheme of the URL. Example 1: C/C++ Code <!DOCTYPE html> <html> <body> <h1
1 min read
Node.js urlObject.path Property
In this article, we will be learning about urlObject.path API. urlObject.path API property is a concatenation of the pathname and search components. Pathname refers to the file path in an URL and search components refer to the query and hash string which has fixed limits such as question mark (?) or
1 min read
JavaScript Location protocol Property
A network protocol defines rules and conventions for communication between network devices. By adopting these rules, two devices can communicate with each other and can interchange information. The protocol property sets or returns the protocol of the current URL, including the colon (:). Syntax: lo
1 min read
Domain Resolution and URL Processing
A domain name is an address that is used to access any website. Domain Name is unique in nature and it is very easy to remember. By typing the Domain Name user can reach the website whichever he desires. The actual address of any website is very complicated but with the help of Domain Name, this com
5 min read