URI vs URL: Differences and When to Use Them

Even though in some cases a uniform resource identifier (URI) and a uniform resource locator (URL) can be used interchangeably, they are not the same.

Knowing the difference between a URI and a URL can make your website development journey more straightforward. For example, you will be able to design a REST API easier, as a URI or a URL will identify each resource on the web.

In short, the main difference between a URI and a URL is that the former can be a name, a location, or both, whereas the latter only provides a resource’s location.

Download eBook: Build Your First Website in 9 Easy Steps

In this article, we will further explain the differences between a URI and a URL and their structure in more detail. Furthermore, we will include use cases from both a URI and a URL together with their pros and cons.

A URI or a uniform resource identifier is a string of characters that generally identifies any web resource by using a name, a location, or both. A uniform resource locator (URL) and a uniform resource name (URN) are the two types of a URI.

Differences Between URI and URL

Check out the comparison table below to better understand the key differences between a URI and a URL.

URI is an acronym for a Uniform Resource Identifier.URL is an acronym for a Uniform Resource Locator.
URI is the superset of a URN and a URL.URL is the subset of URI.
URI identifies a resource and differentiates it from others by using a name, location, or both.URL identifies the web address or location of a unique resource.
URI contains components like a scheme, authority, path, and query.URL has similar components to a URI, but its authority consists of a domain name and port.
An example of a URI is ISBN 0-476-35557-4.An example of a URL would be https://hostinger.com.
URI is usually used in XML, tag library files, and other files, such as JSTL and XSTL.URL is mainly for searching web pages on the internet.
URI scheme can be a protocol, a specification, or a designation like HTTP, file, or data.URL scheme is a protocol, such as HTTP and HTTPS.

URI Types

After finding out the key differences between a URI and a URL, let’s focus on the two types of URIs in detail.

Uniform Resource Names (URNs)

A URN is a persistent and location-independent identifier that aims to identify a resource permanently. It means the resource remains valid even if its data is moved to another location.

To accomplish this, a URN uses the scheme to distinguish resources. For example, urn:isbn:0405999832 identifies a book by using the ISBN numbers.

Every uniform resource name (URN) consists of at least three components:

  • URN – each URN uses the prefix urn: scheme specification.
  • NID – refers to a namespace identifier that should be registered in the Internet Assigned Numbers Authority (IANA). This may include letters, digits, or a hyphen followed by a colon.
  • NSS – this is a namespace-specific string that identifies the internet resource. It may contain ASCII codes, digits, punctuation marks, and special characters.

Uniform Resource Locators (URLs)

A URL specifies the method to obtain a representation of the physical location through the description of the primary access mechanism or its network location. The resources it tries to locate can be a web page, a video, an image, or any document published online.

Unlike a URN, this internet resource identifier is not always persistent and location-independent since it specifies the path to the resource, which may change over time. Also, a URL does not follow the URN scheme.

The main difference between both identifiers is that a URN specifies only a resource’s name, while a URL needs the accessing technique or protocols to retrieve the resource’s location.

In short, all URLs are URIs, but not all URIs are URLs.

URI Syntax

A uniform resource identifier (URI) syntax defines its structure, allowing a program to understand it. Here’s the generic syntax of a URI:


Now, let’s go over the URI syntax elements:


A scheme is the first component of a URI that defines the addressing system. In some cases, URI schemes are a protocol used to access a resource. Meanwhile, other techniques may not specify any protocol.

For example, the about: scheme is used in web browsers, where the resource is built-in the client and not associated with any specific protocol.

It can contain any combination of letters, digits, plus signs, periods, or hyphens followed by a colon. The most common URI schemes include HTTP, HTTPS, FTP, mailto, and file.

For example, if the URI is file:website.com/pathtofile/intro.pdf, the scheme name is file.

Authority Component

It is an optional component preceded by a double slash and terminated by a slash, a question mark, or a hash symbol. It consists of three sub-components:

  • Userinfo – includes a username and a password separated by a colon.
  • Host – consists of either an IP address or a registered name. The IP address should be inserted into brackets.
  • Port – a protocol used for connecting the server. It is an optional sub-component followed by a colon.

For instance, the authority component from file:website.com/pathtofile/intro.pdf is website.com/.


The path contains a sequence of data segments that describes the location of a resource in a directory structure. It should be empty or separated by a slash. For example, telnet:// or foo://info.example.com?fred is a valid URI with an empty path since there’s no indication of the specific resource location.

Query Component

A query is an optional component that contains a query string of non-hierarchical data. It is often a string of key=value pairs. This component is preceded by a question mark. For example, if the URI is https://example.org/test/test1?search=test-question#part2, the query component is search=test-question.

Fragment Component

This optional component includes a fragment identifier that provides the direction to a secondary resource. It refers to a different section of the primary resource. A fragment is preceded by a hash symbol and terminated by the end of a URI.

For instance, the fragment component from https://example.org/test/test1?search=test-question#part2 is part2.

A URL or a uniform resource locator is an identifier that only indicates the location of a web page. It refers to a web address and its access possibilities, such as HTTP, FTP, and mailto.

URL Syntax

Each URL should follow the URI syntax that has a similar structure to a URI. Below is an example of URL syntax:


The above URL can be divided into the following components:


The first part of the URL syntax is a protocol used to retrieve a resource. A URL scheme provides the type of application your device uses to open a URL. For example, FaceTime uses a URL scheme facetime:// to make calls. Other most used protocols for URL schemes include:

  • Hypertext transfer protocol (HTTP) – allows users to access data from web pages using hypertext links.
  • Hypertext transfer protocol secure (HTTPS) – protects data transmission between the user’s browser and site.
  • File transfer protocol (FTP) – used for a file transfer between different devices via a network.

Furthermore, some URL protocols use a mailto link to identify email addresses or a JDBC to specify database access based on the user’s requirements.


This component is preceded by a double slash. It contains two sub-components – a domain name and a port, the resource you’re accessing. The domain name is the registered name of the resource, such as hostinger.com or google.com.

Pro Tip

If you have a good idea for your domain name, don’t forget to check its availability on a domain checker.

As for the port, it is the specific number that identifies which web service you’re requesting on a web server. For example, the port number for HTTP URL is 80 and for HTTPS URL is 443. However, if the web server uses a standard protocol like HTTP or HTTPS, the port is usually omitted from the URL.


This element identifies the specific location of a web page, a post, or other files that users want to access within the domain name. A path also contains any asset file extension, such as images and documents.

However, not all URLs show the path component. In many modern web servers, you may not see a path component as it can be omitted for shortening the URLs. Some examples for paths are …/software/htp/index.html or …/forum/question/.

Query String

This string delivers data about the resource on the web server and is preceded by a question mark. It usually contains a key and value pairs separated by an ampersand. For example, ?tag=networking&order=newest.

The query string stores data as the HTTP protocol is stateless. It means each request is independent and does not relate to the previous request. As a result, the connection between a browser and a web server will be closed automatically once the client request ends.

In addition, the string is known as URL query parameters that can be used for some purpose, such as search results for a web page. It will help users browse content from a resource. For example, users can easily find information about products in an online store.

Fragment Identifiers

A fragment identifier or an anchor usually appears at the end of a URL and is introduced by a hash sign. It is an optional component to direct a web browser to a secondary resource. It refers to a specific section within a web page.

In an HTML page, the browser will jump to the specific section tagged by a fragment.

For example, if the URL is https://example.com/results.html#intro, it will directly go to the tagged intro on the page named results.html.

Reasons to Use a Uniform Resource Identifier (URI)

Using a URI helps create standard rules for using a resource, including accessing, updating, finding, or downloading it. It provides a simple way to identify internet resources.

Here are three use cases of a URI:

  • Audiovisual works – ISAN is a serial code number used to identify audiovisual works and versions, like films, television programs, or documentaries. By using the urn: scheme, URI can identify ISAN without a protocol or a way to access it. For instance, urn:isan:0000-0000-2CEA-0000-1-0000-0000-Y, which refers to the 2002 Spider-Man movie. It identifies a resource using an audiovisual number without telling the user where to find it.
  • Telephone numbers – a URI can identify a resource using a dial string, which has a network termination point (NTP) that contains the information needed to route the call. The tel: scheme is only a Globally Unique Identifier (GUID) and doesn’t refer to any physical device. For example, tel:+1-816-555-6666 describes a GUID as the standard telephone number in the USA.
  • Remote access – Telnet is a network protocol where URIs use it to specify access to a remote computer or host via the internet. For example, telnet:// Telnet is commonly used to test or troubleshoot web or mail servers remotely.

Now, let’s see what benefits and drawbacks a URI has:


  • Unambiguous identifier – a URI can prevent ambiguity by providing unique schemes to identify resources and differentiate them on the semantic web. It helps a resource description framework (RDF) to interpret information for the users. Thus, there’ll be no confusion between web documents and other resources.
  • Uniformity – a URI identifies the name and the location of a resource. Also, different types of resource identifiers can be used in the same context. For example, a URL and a URI can refer to the same resource. Uniformity refers to the general syntax of URI that should be followed.
  • Identify abstract and physical resources – URI schemes can specify any resource, including real-world objects, such as telephone numbers, places, books, and people. The resource is not necessarily limited to web pages that are accessible through the internet.
  • Multiple URIs can be linked with one resource – for example, the data on http://www.example.com/abc/2022/Q1 might also be available at http://www.example.com/abc/Q12022. This will make the client-server easier to refer to a resource.


  • URIs should be permanent – once you have created a URI, changing it can damage your website’s reputation. Even though you still can re-encode broken URLs, it takes time and effort.
  • Not compatible with all browsers – although URIs can be used in many popular browsers, such as Google Chrome and Mozilla Firefox, some old version browsers like Internet Explorer 5,6,7, or Safari 5 and 6 are not supported by the URIs scheme.

Reasons to Use a Uniform Resource Locator (URL)

Like a URI, a URL is used to identify a resource. Both have subtle differences in terms of their purpose and structure. Keep in mind that most URLs provide a protocol. Here are some use cases of a URL:

  • Referring to an email address – a URL can specify an email address by using a mailto: scheme. It provides a hyperlink to send an email directly from an HTML page. For example, mailto:abc@example.com.
  • Retrieving web pages – the most common URLs refer to a web address. It contains a protocol, a domain name, and a path. It is also known as an absolute URL. For example, https://www.example.com/news/business/ tells you the address and its directory to the resource.
  • Redirecting a resource – you can use a URL to redirect an old resource to a new location. It is usually used for moving a webpage. For instance, if you changed your website address from https://www.blog.example.com to https://www.example.com/blog, you could implement a 301 redirect. Doing so will prevent visitors from getting various HTTP status codes, such as a 404 error page.
  • Referring to an internal page – URLs can be displayed without a protocol and a domain name but only indicates a path. It is used to link a specific file within the same domain, which can be called a relative URL. For example, if the URL is https://www.example.com/news/business/, the relative URL will be /news/business/.

Every URL consists of several components that will affect your site’s security and search engine optimization (SEO). Let’s find out about its pros and cons.


  • Enhance user experience – a well-structured URL will help users understand what page they are accessing. For example, if the website www.example.com has the title tag “Chocolate Pudding Recipe for Christmas” on its web page, your URL can be http://example.com/recipes/chocolate-pudding to describe the page’s content clearly.
  • Improve the site’s ranking – besides the domain’s authority, keywords in URLs act as a minor ranking factor for your website. It may affect the search engine results pages (SERP) in analyzing a specific page or a resource’s relevance.
  • Secure your site – using HTTPS URLs can protect your website and visitors’ privacy more securely than an HTTP. It is because HTTPS comes with a Secure Sockets Layer (SSL) certificate that provides an encrypted connection between a web server and a web browser for data transmission.


  • Security threatening – creating a shortened URL can also risk your website’s reputation. Many hackers use URL shorteners, such as Bitly, owl.ly, AdF.ly, and TinyURL, to hide their malicious intent from the users. An example of a shortened URL is http://bitly.is/example, where you cannot see a site’s domain.
  • Content stealing – using relative URLs may be risky for content theft since people don’t have to rewrite any internal links. They can easily copy your page and put it on a new domain by using a web scraper.
  • Dead link – this can happen when you’re using a URL shortening service. This is because a service may go down or even discontinue, making your link not work.

Pro Tip

Good URLs should be simple, definitive, and concise. This way, users can get an idea of what to expect on the page.


Understanding the differences between a URI or a URL and their usage is essential for evey webmaster. For example, building a REST API using a predictable and hierarchical structure of a URI or a URL can improve the REST API performance.

A URI stands for a uniform resource identifier, a character string that generally identifies a resource by a name, location, or both on the internet. Also, a URI can differentiate types of files and other resources.

On the other hand, a URL or uniform resource locator is a string of characters that shows the resource’s address and how to access it on the web page. As URL is a part of a URI, they follow a similar structure.

We hope this article has helped you understand the difference between a URI and a URL and when to use them. Finally, if you have any further questions, feel free to share them in the comments section below!

Was this tutorial helpful?

The author

Sopha Mutia Adinda

Dinda is a Content Writer at Hostinger. She is passionate about WordPress and digital marketing and enjoys sharing her knowledge to help people succeed. During her free time, Dinda likes to watch movies and go to historical places.