URLs (Uniform Resource Locators) are the addresses used to locate resources on the internet.
There are several types of URLs based on their structure and the kind of resource they point
to. Below are the main types of URLs:
1. Absolute URL
An absolute URL provides the complete path to a resource, including the protocol, domain
name, and full location of the resource on the server. It gives the complete address of a
webpage or file.
Example:
arduino
Copy code
[Link]
Protocol: https
Domain Name: [Link]
File Path: /[Link]
2. Relative URL
A relative URL refers to a resource in relation to the current page or location. It doesn’t
include the protocol (http:// or [Link] or domain, and it is used when the resource is
within the same domain or website.
Example:
bash
Copy code
/images/[Link]
This points to an image file located in the /images directory on the same website.
Relative URL with respect to a page:
Copy code
[Link]
This links to the [Link] page, assuming the link is within the same directory
as the current page.
3. Root-relative URL
A root-relative URL starts with a forward slash (/) and points to a resource starting from the
root directory of the website, but it doesn’t include the domain name.
Example:
bash
Copy code
/about/[Link]
This points to the [Link] file in the /about directory, starting from the root of
the website.
4. Protocol-relative URL
A protocol-relative URL omits the protocol (e.g., http:// or [Link] and relies on the
protocol used by the page currently being viewed. It automatically adjusts to the protocol of
the page (secure or non-secure).
Example:
arduino
Copy code
//[Link]/images/[Link]
This URL will use the same protocol (either http or https) as the current page.
5. URN (Uniform Resource Name)
A URN is a type of URL that identifies a resource by name within a given namespace,
without giving its location. URNs are primarily used to identify resources in persistent,
location-independent ways.
Example:
css
Copy code
urn:isbn:0451450523
This URN points to a specific book identified by its ISBN number, but it doesn’t
provide the location of the book.
6. Data URL
A data URL embeds the data of the resource directly into the URL itself, rather than linking
to an external file. This is used for small files, such as images or text.
Example:
bash
Copy code
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
This URL represents an image file encoded in Base64 format.
7. File URL
A file URL refers to a local file on a computer or network. It typically starts with [Link]
indicating that the resource is stored on the file system rather than a remote server.
Example:
perl
Copy code
[Link]
This URL points to a file on the local machine in the C:/Users/John/Documents/
directory.
8. FTP URL
An FTP URL is used to access files over the FTP (File Transfer Protocol). It allows the
transfer of files from one machine to another.
Example:
arduino
Copy code
[Link]
This URL points to a file [Link] in the /pub directory on an FTP server.
9. mailto URL
A mailto URL is used to create a link that opens an email client with the recipient's email
address pre-filled.
Example:
graphql
Copy code
[Link]
Clicking this URL will open the default email client with the recipient’s email address
filled in.
10. Tel URL
A tel URL is used to link to a phone number, which, when clicked, will prompt the device to
dial the number (useful in mobile environments).
Example:
makefile
Copy code
[Link]
This will initiate a call to the phone number +1234567890.
Summary of URL Types:
Type of URL Description Example
Absolute Full URL, includes protocol, domain, [Link]
URL and file path
URL relative to the current page's
Relative URL location, no protocol or domain /[Link]
needed
URL starting from the root directory
Root-relative
of the website, no domain but starts /images/[Link]
URL
with a slash /
Protocol- URL without the protocol, uses the //[Link]/about
relative URL same protocol as the current page
Identifies a resource by name within a urn:isbn:0451450523
URN
namespace, location-independent
Embeds data directly into the URL
Data URL itself (e.g., Base64 encoded image data:image/png;base64,...
data)
URL to a local file on a computer or [Link]
File URL
network (starts with [Link]
FTP URL URL to access files over FTP protocol [Link]
URL that opens the default email
mailto URL [Link]
client with an email address pre-filled
URL that initiates a phone call by
tel URL [Link]
dialing a specified number
Each type of URL serves a unique function depending on the resource you're trying to access
or the action you're trying to perform.
A URL (Uniform Resource Locator) consists of several components that together specify
the address of a resource on the web. Here’s a breakdown of the structure of a URL:
General Structure of a URL:
bash
Copy code
scheme://domain:port/path?query#fragment
Let's go through each component:
1. Scheme (Protocol)
Definition: This part specifies the protocol or method used to access the resource.
Example: http, https, ftp, mailto, etc.
Purpose: It tells the browser or application which protocol to use when accessing the
resource.
Example: https:// indicates that the HTTP protocol is used with encryption (SSL/TLS).
2. Domain (Host)
Definition: The domain name identifies the server where the resource is hosted.
Example: [Link]
Purpose: It’s the address of the server or machine that is hosting the resource. This
can be a fully qualified domain name (FQDN) or an IP address.
Example: [Link] refers to the server hosting the resource.
3. Port
Definition: The port is an optional component that specifies the port number on the
server to which the request is sent. If omitted, the