URL, URI, URN: What's the Difference?
Tags: webdev, security, programming
Published: 2022-04-29 11:17:33

### Let's try to shed some light on the differences between URL, URI, and URN.

### <br>

While most developers know what a URL is, not everyone knows what a URI is, and even less knows about URNs. Not to mention that the relationship between these items is not always very clear. Let's clarify in simple words the difference.

## What Is a URL?

We have to deal with URLs every day. URL is an acronym that stands for *Uniform Resource Locator*. Maybe the expanded name may sound weird, but you can simply call it *address*. The term address explains very well the role of a URL. You can think of a URL like your home address: it contains all the information to find your home.

Similarly, you can [define a URL](https://datatracker.ietf.org/doc/html/rfc1738) as a string that denotes the location of a given resource on the Internet: a web page, an image, a mailbox, etc. The following are examples of URLs:

```
https://jwt.io
https://auth0.com/docs/get-started#learn-the-basics
https://identicons.dev/static/icons/mono/png/icon-access-token.png
mailto:yourfriend@somewhere.com
ftp://ftpserver.com/myfolder
```

### URLs and links

While the terms URL and link are commonly used interchangeably, technically they are not synonyms. A URL is a string that allows you to locate a resource. A link (short for hyperlink) is an HTML element that enables you to load a resource from a given URL in a browser. So, a link relies on a URL, and a URL can exist without a link, but a link without a URL makes no sense (at least in [its original meaning](https://christianheilmann.com/2019/02/05/links-that-dont-go-anywhere-should-be-buttons/)).

### Anatomy of a URL

The *Uniform* part of the URL acronym is about a common structure of these locator strings. The following image shows this standard structure:

![Structure of a URL with all its parts](https://images.ctfassets.net/23aumh6u8s0i/67pmAyqHVJOOSlR4hVGkrS/5cd75492ee2ffba9720906099236939c/url-anatomy.png)

An URL consists of the following parts:

- *Scheme*: in a URL, this is the protocol that should be used to access the resource. Beyond the well-known HTTP and HTTPS, you can use [many other schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml).
- *Domain*: this part indicates the server hosting the resource. It can be a [domain name](https://en.wikipedia.org/wiki/Domain_name) or an IP address.
- *Port*: it is the protocol port to which to send the request to access the resource. Usually, it is omitted, meaning that the default protocol port should be used.
- *Path*: this is the path to the resource on the hosting server.
- *Parameters*: these are optional extra information provided to the hosting server.
- *Anchor*: this part represents a specific part inside the resource. It is also called *fragment*.

The group consisting of the domain name and the port, if present, is also known as *authority*. The scheme and the authority are separated by the string `://`. If a URL has no authority, the scheme and the rest of the URL are separated only by the colon `:`. A typical example of a URL without the authority part is the URL representing an email address, such as `mailto:yourfriend@somewhere.com`.

[Read more...](https://auth0.com/blog/url-uri-urn-differences/?utm_source=content_synd&utm_medium=sc&utm_campaign=security)