URI vs. URL: What’s the Difference?

Anna Fitzgerald
Anna Fitzgerald

Published:

There are so many resources available on the internet today, from web pages to images to weather reports and electronic documents. It’s important to be able to identify and retrieve these different resources.

Website owner learning difference between uri and url

To do so, you’ll need to know what a URI and URL are and how they’re different. Let’s define each of the terms below, then explain their key differences.

Speed Up Your Website with HubSpot's Built-In CDN

What is a URI?

A URI — short for “Uniform Resource Identifier” — is a sequence of characters that distinguishes one resource from another.

For example, foo://example.com:8042/over/there?name=ferret#nose is a URI containing a scheme name, authority, path, query and fragment. A URI does not need to contain all these components. All it needs is a scheme name and a file path, which can be empty.

Here’s another example of a URI: telnet://192.0.2.16:80/. In this example, “telnet” is the scheme name and the numbers after the double slash make up the authority. The path is empty, which is why no characters come after the slash

Types of URI

There are two types of URIs: URNs and URLs.

A Uniform Resource Name (URN) is a persistent and location-independent identifier that follows the “urn” scheme. In this context, “persistent” means that the URN persists in identifying the same resource over time. Here’s an example of a URN provided by the RFC 3986: urn:oasis:names:specification:docbook:dtd:xml:4.1.2

A URL, on the other hand, is a location-dependent identifier that is not necessarily persistent. Meaning, URLs are not required to identify the same resource over time. URLs also do not follow the “urn” scheme.

Now that we have a brief understanding of URIs, URLs, and URNs, let’s take a closer look at what URLs are below.

What is a URL?

A URL — short for “Uniform Resource Locator” — is a specific type of identifier that not only identifies the resource but tells you how to access it or where it’s located. For example, a URL might contain ftp:// or https://. This tells you that the resource can be located and accessed via File Transfer Protocol (FTP) or Hypertext Transfer Protocol Secure (HTTPS).

Here are some examples of URLs:

  • ftp://ds.internic.net/internet-drafts/draft-ietf-uri-irl-fun-req-02.txt
  • https://blog.hubspot.com/website/application-programming-interface-api
  • http://www.ietf.org/rfc/rfc2396.txt
  • https://offers.hubspot.com/how-to-run-seo-audit?hubs_post-cta=anchor&hsCtaTracking=f55ac8df-26f8-41f5-b63a-fa80e97d2fec%7Cfe8e963d-d682-4a22-b84e-52f7d60e4786

You’ll notice that these look similar to the URI examples mentioned above. That’s because they contain many of the same components, including path and query.

However, a URL contains unique components, such as protocol and domain, as well. In the last URL example, “https://” is the protocol. “Offers” is the subdomain, and “hubspot.com” the domain name. “How-to-run-seo-audit” is the path, and the question mark and everything after makes up the query. 

Now let’s take a closer look at the difference between a URI and a URL.

URLs are therefore a specific subset of URIs. Meaning, all URLs are URIs, but not all URIs are URLs.

The most common analogy used to understand the difference between URIs and URLs is comparing a person’s name vs. their address. A person’s name is like a URI because it identifies the person without providing any information on how to locate them. An address, however, identifies the person as resident of that address and provides their physical location. That’s why it’s like a URL.

The other major difference is that URIs can be used to identify and differentiate HTML, XML, and other files from each other. URLs, on the other hand, can only be used to identify and locate web pages.

Identifying and Locating Resources on the Web

With millions of resources available on the web, it's important to understand the proper way of identifying and locating individual resources. While URIs are used to identify resources with either a name or location, URLs are a subset of URIs that identify resources by how you access them. 

uri-v-url_0

 

Speed Up Your Website with HubSpot's Built-In CDN

GET HUBSPOT'S BUILT-IN CDN

CMS Hub is flexible for marketers, powerful for developers, and gives customers a personalized, secure experience

START FREE OR GET A DEMO