0% found this document useful (0 votes)
39 views5 pages

URLs

types of urls

Uploaded by

carlosmaina198
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views5 pages

URLs

types of urls

Uploaded by

carlosmaina198
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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
https://www.example.com/index.html

 Protocol: https
 Domain Name: www.example.com
 File Path: /index.html

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 https://) or domain, and it is used when the resource is
within the same domain or website.

Example:

bash
Copy code
/images/logo.png

 This points to an image file located in the /images directory on the same website.

Relative URL with respect to a page:

Copy code
about-us.html

 This links to the about-us.html 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/contact.html

 This points to the contact.html 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 https://) 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
//www.example.com/images/banner.jpg

 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 file://,
indicating that the resource is stored on the file system rather than a remote server.
Example:

perl
Copy code
file:///C:/Users/John/Documents/example.txt

 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
ftp://ftp.example.com/pub/file.txt

 This URL points to a file file.txt 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
mailto:[email protected]

 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
tel:+1234567890

 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, https://www.example.com/about
URL and file path
URL relative to the current page's
Relative URL location, no protocol or domain /contact.html
needed
URL starting from the root directory
Root-relative
of the website, no domain but starts /images/logo.png
URL
with a slash /
Protocol- URL without the protocol, uses the //www.example.com/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 file:///C:/Documents/report.txt
File URL
network (starts with file://)
FTP URL URL to access files over FTP protocol ftp://ftp.example.com/file.txt
URL that opens the default email
mailto URL mailto:[email protected]
client with an email address pre-filled
URL that initiates a phone call by
tel URL tel:+1234567890
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: www.example.com
 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: www.example.com 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

You might also like