A website is similar to a house. If one wants to find you he might need to get your address. Similarly, the document that’s present on the website is represented by a website address known as URL(Uniform Resource Locator). In this article, we are going to learn about URLs, their types, and their components.
What is URL?
The acronym URL stands for Uniform Resource Locator. It defines the address of a given resource on the web. The resource can be anything like an HTML page, image, document, etc.
A URL can also redirect to other resources that are present on the network such as command output or database queries. URL is a type of a URI(Uniform Resource Identifier).
Some examples of URLs are –
If you type any of the above-given URLs in the address bar of your browser you will be redirected to the associated page.
Parts of URL
A URL consists of various parts, these are – protocol, domain, and file path. Let’s discuss each of them in detail.
The scheme or protocol of an URL signifies how webpages and servers exchange data. For example, A lot of websites we are familiar with using the protocol HTTPS(Hypertext Transfer Protocol Secure) or HTTP(Hypertext Transfer Protocol). Some other examples of protocols or schemes are FTP(File Transfer Protocol) for sending large files over the web and Mailto for mails.
The domain is a human-friendly text string that is used to access a particular website from the browser. Domain makes the access to a website easier by mapping its IP Address.
For example in the URL – https://artoftesting.com/software-testing-tutorial
Domain name- artoftesting.com
The string starts with the forward-slash(/) character and consists of directories or folder names. The file path usually comes after the domain name.
For example in the URL – https://artoftesting.com/what-is-a-web-browser
File path- /what-is-a-web-browser
Other Parts of the URL
A query is also known as a fragment identifier and is conceded by a question mark(?). It is used to indicate a specific page or to do internal searches within the webpage. The use of a fragment identifier in the URL suggests the web browser goes straight away to the specified destination.
With the help of UTM Parameters, we can add additional information to a website. Parameters are added after the fragment identifiers. These are used as a traffic tracker for a website and multiple parameters can be added to a URL with the help of the ‘&’ symbol.
It acts as a bookmark of a resource directing the web browser to go to the anchor spot. It is represented by ‘#’ and is also called a jump link.
Types of URL
The URLs can be categorized into two categories:
- Absolute URLs
- Relative URLs
Absolute URLs – The absolute URL carries all the information of the resource that is mandatory for finding the files on the web. If anything is missing from the URL such as protocol or hostname the browsers would be unable to link the file as the browser will become unaware of the location of the file.
Relative URLs – In the case of relative URLs even if protocol or server name are missing, browsers would be able to open the file as relative URLs typically contain the file or folder name.
Characters Allowed in URL
The World Wide Web Consortium is responsible for the characters that are allowed in URLs. There are two types of characters that are specified
- Unreserved Characters
- Reserved Characters
Unreserved Characters – These are the characters that are unreserved and are freely allowed in the URLs. Digits, a hyphen, periods, lowercase, uppercase, etc. These characters don’t have any special meaning in the URL.
Reserved Characters – Reserve characters provide differentiating data within the URL from the set of delimiting characters.They include / ; : ? @ & , + $ =. For example, if we want to display ‘?’ as a question mark or ‘-’ as a minus sign in a URL string we require to encode them.
This is the end of the article covering some important aspects of URL and their types. Thanks for reading.