What is the difference between URI and URL with examples?

URI and URL are two commonly confused terms when referring to online addresses. So what is the difference between URL vs URI?

Updated: 12 Jan, 23 by Susith Nonis 10 Min

List of content you will read in this article:

URI and URL are two commonly confused terms when referring to online addresses. URI is short for “uniform resource identifier”, and URL stands for “uniform resource locater”, which are two different things.

The main difference between URI and URL is that a URL is a part of a URI but not the other way around. Knowing the URL vs URI definition can help you develop each page better if you want to build a website. Because these two will identify resources on each page and affect website ranking on search engines.

Here, we’ve gathered a complete guide about URLs and URI, along with examples. Moreover, we’ll lay out how each is used and what are their advantages and disadvantages. Keep reading to find out more!

URI is a web resource identifier like a line of characters that uses a name, a location, or both to identify different websites’ resources. So, a URI can be a uniform resource locator (URL), a uniform resource name (URN), or both.

On everyday use, we encounter a lot of resources on the Internet. A URI identifies those resources and gives them a unique form using a name, a location, or both.

URI examples

URI respectively consists of the following parts:

  • Scheme: The first part of URI may contain letters, digits, hyphen, or a plus sign. For instance, HTTP, IRC, FTP, HTTPS, idap, data, file, and telnet are the most commonly used schemes in URI. A colon mark follows each scheme.
  • Authority: A user info, host, or port form the authority part. You can add this part to a URI or not. Generally, two slashes come before an authority.
  • Path: A URI identifies a path and specifies each section by using a slash.
  • Query: Just like Authority, adding a query to the URI is optional. A query contains a question mark followed by a string of non-hierarchical data.
  • Fragment: A fragment comprises a hash and an identifier that directs you to a secondary resource.

So, the overall syntax will look like this:

scheme:[//authority]path[?query][#fragment]

To summarize, a scheme and a path are the essential parts of the URI. The other parts are optional and are used based on website type. For instance, the following is a URI that contains all the parts mentioned above:

https://may.smith@www.sample.com:889/forum/questions/?tag=content&marketing=latest#top

Other examples of a URI:

  • ISBN 0-476-33357-2
  • urn:isbn:0-284-54459-3

As you understood, the difference between URI and URL is that URL is a part of URI. In simple words, a URL is a location finder. A URL can be anything from an HTML or CSS page to an image or a document as long as it refers to and shows the way to a unique resource. A Uniform resource locator consists of a protocol like HTTP, FTP, etc., that shows how to access a resource. 

When you click on a website’s link, the address in the address bar is the URL that refers to the website’s specific resources. 

URL examples

URI and URL have similar syntax. So, a URL is also made up of a scheme, authority, path, query, and fragment. The first part of the URL scheme uses a specific protocol to retrieve the resource name. For example, the following is a URL:

https://www.sample.org/the-difference-between-uri-and-url

Different protocols in a URL refer to different resources. For instance, HTTP and HTTPS refer to resources on a website, while FTP may refer to a mailto or file in an email address.

To put it in simple words, the main difference between URL and URL are as follows:

  • URI is a uniform resource identifier, while URL is a uniform resource locator.
  • URL is also a URI. Therefore, URI is the superset of both URLs and URN.
  • URL uses a location to identify a web page, whereas URI uses a name, a location, or both to differentiate a resource from others.
  • URL and URI have similar syntax with only one difference: the authority part of a URL only contains a host and port.
  • URL scheme is a protocol, whereas a URI scheme may be a specification, protocol, or even a designation.
  • URL is used only in the address bar of a web page, but URI can be used in XML, JSTL, XSTL, and other files.
  • URI defines a technique to identify an object, whereas URL describes the identity of that object.

Now that you understand the difference between URI and URL let’s go through two types of URI in more detail: URL and URN. Knowing the definition and difference between URN and URL will create a more straightforward path to your developing journey.

URN 

URN or uniform resource name is a type of identifier that identify resources by their name. Unlike URL, when a URN identifies data, it remains valid forever. Even if you change the location of resources, their URN remains persistent because it depends on the name of the resources, not their location.

URN uses a scheme to differentiate one resource from another. For instance, urn:isbn:06820647849 refers to a book using the ISBNs. Each URN contains three parts:

  • Urn prefix: A URN scheme specification; an urn followed by a colon.
  • NID: Each resource name must be registered in IANA (Internet Assigned Number Authority). This name will be placed in the namespace identifier part of a URN, followed by a colon. The name can consist of letters, a hyphen, or digits.
  • NSS: This term is short for namespace-specific string. The Internet resource identifier may contain digits, punctuation marks, ASCII codes, or characters.

URL

URL uses the path to a resource to identify it. As a result, it depends on the resource’s location to find and access it through the Internet. The resource can be a web page, a specific video or image, a document, etc.

So, unlike URN, URL is not persistent. If the path to the resource changes, the URL will also change. The main difference between these two types of URI is that URN only refers to a resource’s name, while URL uses protocols to access a resource’s location.

The Internet is a huge world full of resources. To use the Internet and access different websites easily, we need to define rules to sort the resources out. That’s what URI is used for identifying and sorting Internet resources.

A URI is used for:

  • Identifying ISAN: Audiovisual works like documentaries, films, etc., can be identified by a serial code called ISAN. For instance, isan:0000-0000-2CEA-0000-1-0000-0000-Y is an ISAN code that refers to a spider man movie. With the help of URI, we can add the urn: scheme to identify this name and show the users where they can find it.
  • Identifying phone numbers: URI can also use dial strings to identify a resource. Tel: scheme is used as a GUID to identify specific phone numbers without referring to a specific device. For instance, tel:+1-816-555-6666 refers to a telephone number in the USA.
  • Access remotely: if you want to access a computer or server, you can use the telnet: URI scheme. We use the telnet scheme to troubleshoot or test servers remotely.

Although URL is a subset of URI, they don’t have similar purposes or structure. URI can define a structure for URLs. However, in general, their use cases are different.

A URL is used for:

  • Indicating an email address
  • Referring to a web page
  • Changing a resource location
  • Indicating a path whiting the same domain

Pros:

  • It can have a positive impact on a website’s SEO.
  • Well-structured URLs can improve user experience.
  • Keywords used in URLs can increase a website’s ranking.
  • It comes with more layers of security for sites. HTTPS scheme secures your website way stronger than HTTP. 

Cons:

  • Many hackers use URL shorteners to penetrate websites and use users’ data. So, URLs can also threaten a site’s security.
  • People can copy a content’s URL to steal the content itself without having to rewrite the whole page.
  • If you use a URL shortening program, it can go down and make your URL unusable.

Pros:

  • URI helps RDF (resource description framework) describe information for users and avoid confusion between web documents and other resources.
  • URI gives a unique form to resources. It identifies resources by their name and location and puts them in a specific context. As a result, other identifiers, such as URLs, can use the same context. For instance, sometimes, a URI and URL indicate the same resource.
  • URI schemes can refer to any physical or abstract object. For example, it can specify real-world phone numbers, books, etc., and web pages on the Internet.

Cons:

  • It’s permanent. If you define a URI for your website, book, or other resources, you can’t change it. If you replace your URI with another, people won’t be able to find the resource anymore, and it will ruin its reputation.
  • You can’t use it on all browsers. Although Google Chrome and Mozilla Firefox support the URI scheme, other browsers like Safari are incompatible.

Knowing the difference between a URI and a URL can help you create a better website. A URL identifies a resource by its location, while a URI can identify an abstract or a physical resource by its name, name and location, or both.

Understanding these terms and their usage allows you to define better URLs or URI for your resources based on your needs. As a result, make them more findable and accessible by using different means.

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.