URL and URI

The difference between URL and URI with example

URL and URI are two commonly confused terms when referring to online addresses. URI stands for “Uniform Resource Identifier”, and URL stands for “Uniform Resource Locator”, which are two different things.

The main difference between a URL VS URI is that a URL is a part of a URI but not the other way around. If you want to build a website, knowing the definition of URL vs URI can help you develop each page better. Because these two will identify the assets on each page and affect the website’s ranking in search engines.

Here, we have collected a complete guide about URLs and URIs with examples. Furthermore, we will determine how each is used and what their advantages and disadvantages are. Continue reading to learn more!

What is a URI?

A URI is a web resource identifier such as a string of characters that uses a name, a location, or both to identify a resource on a different website. Thus, a URI can be a Uniform Resource Locator (URL), a Uniform Resource Name (URN), or both. In daily use, we encounter a lot of resources on the Internet. A URI point outs those resources and gives them a unique form using a name, a location, or both.

URI examples

The URI consists of the following parts respectively:

Scheme: The first part of the URI can contain letters, numbers, hyphens, or a plus sign. For example, HTTP, IRC, FTP, HTTPS, idap, data, file, and telnet are the most commonly used URI schemes. A colon mark follows each scheme.

Owner: Forms part of the information for a user, host, or port. You may or may not append this part to a URI. Usually, a partner comes with a different slash.

Path: A URI identifies a path and specifies each section using a slash.

Query: As with authority, adding a query to the URI is optional. A query consists of a question mark followed by a string of non-serial data.

Fragment: A fragment consists of a hash and an identifier that points you to a secondary resource.

So, the overall syntax would look like this:

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

In short, a scheme and a path are the essential parts of a URI. Other parts are optional and used based on the type of website. For example, the following is a URI that contains all the parts mentioned above:

https://[email protected]:889/forum/questions/?tag=content&marketing=latest#top

Other examples of a URI:

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

What is a URL?

As you understand, the difference between URI and URL is that URL is a part of URI. Simply put, 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 points to and points to a unique resource. A uniform resource locator has a protocol, such as HTTP, FTP, etc., that shows how to access a resource.

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

URL examples

URIs and URLs have the same syntax. So, a URL is made up of a scheme, authority, path, query, and fragment. The first part of a URL scheme uses a specific protocol to retrieve the name of the resource.

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

Different protocols of a URL refer to different resources. For example, HTTP and HTTPS refer to a website’s resources, while FTP can refer to an email address or a file.

What is the main difference between a URL and a URI?

To put it simply, the main difference between URL and URL is as follows:

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

What are the other types of URIs?

Now that you understand the difference between URIs and URLs, let’s go through the two types of URIs in more detail: URLs and URNs. Knowing the definition and difference between URN and URL will make your development journey smoother.

URN

A URN or Uniform Resource Name is a type of identifier that identifies resources by their name. Unlike a URL, when a URN identifies data, it remains valid forever. Even if you change the asset’s location, its URN remains constant because it depends on the asset’s name, not its location.

URN uses a scheme to distinguish one resource from another. For example, urn:isbn:06820647849 refers to a book using ISBN. Each URN has three parts:

  • Urn Prefix: A URN scheme specification; A pitcher followed by a colon.
  • NID: Each resource name must be registered with IANA (Internet Assigned Numbers Authority). This name is placed in the namespace identifier part of a URN, followed by a colon. The name can contain letters, a hyphen, or digits.
  • NSS: This term is short for Namespace-Specific String. Internet resource identifiers can contain numbers, punctuation marks, ASCII codes, or letters.

URL

The URL uses a resource path to identify it. Consequently, it depends on the location of the resource to be searched and accessed over the Internet. Assets can be a web page, a specific video or image, a document, etc.

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

In the case of using a Uniform Resource Identifier (URI).

The Internet is a vast world full of resources. To use the Internet and access various websites easily, we need to define rules to organize resources. This is the URI used to identify and sort Internet resources.

A URI is used for:

ISAN Identification: Audiovisual works like documentaries, films, etc. can be point outed by a serial code called ISAN. For example, isan:0000-0000-2CEA-0000-1-0000-0000-Y is an ISAN code that refers to a Spider-Man movie. With URIs, we can add the urn: scheme to identify this name and show users where they can find it.

Phone number identification: URIs can use the dial string to identify a resource. Telephone: scheme is used as a GUID to identify specific phone numbers without specifying a specific device. For example, tel:+1-816-555-6666 refers to a telephone number in the United States.

Access remotely: If you want to access a computer or server, you can use the telnet: URI scheme. We use the Telnet scheme to remotely troubleshoot or test the server.

In the case of using a Uniform Resource Locator (URL).

Although URLs are a subset of URIs, they do not have the same purpose or structure. URIs can define a structure for URLs. However, in general, their uses are different.

A URL is used for:

  • Indicates an email address
  • Referencing a web page
  • Change the location of an asset
  • The same domain indicates a path to whitening

URL pros and cons

Pros:

  • This can have a positive impact on a website’s SEO.
  • Well-structured URLs can improve user experience.
  • Keywords used in URLs can increase the ranking of a website.
  • It comes with more level of site security. The HTTPS scheme protects your website more strongly than HTTP.

Cons:

  • Many hackers use URL shorteners to break into websites and use users’ data. Thus, URLs can also threaten a site’s security.
  • People can copy a content URL to steal the content without rewriting the entire page.
  • If you use a URL shortening program, this can go down and make your URLs unusable.

URI pros and cons

Pros:

  • URIs help RDF (Resource Description Framework) users describe information and avoid confusion between Web documents and other resources.
  • URIs give resources a unique form. It identifies resources by their name and location and places them in a specific context. Consequently, other identifiers, such as URLs, may use the same context. For example, sometimes, a URI and URL refer to the same resource.
  • The URI scheme can refer to any abstract or physical object. For example, it may specify real-world phone numbers, books, etc., and web pages on the Internet.

Cons:

  • It is permanent. If you define a URI for your website, book, or other resources, you cannot change it. If you replace your URI with another one, people will no longer find the resource and it will ruin its reputation.
  • You may not use it in all browsers. While Google Chrome and Mozilla Firefox support the URI scheme, other browsers such as Safari are incompatible.

Conclusion

Knowing the difference between a URI and a URL can help you build 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, location, or both.

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

Scroll to Top