Thursday, 11 November 2021

URI vs URL

While working with web applications, you may come across the terms URI and URL. Most of the people think that both URI and URL are same, but actually not.

 

In this post, lets’ dig into it and try to understand the difference between URI and URL.

 

What is URI?

A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.

 

Syntax of URI

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

Examples

ftp://xyz.ab.com/text/text1808.txt
http://www.abc.xy.org/text/text2396.txt
mailto:ram.krishna@example.com
news:comp.abc.www.servers.unix
tel:+1-987-123-1212
telnet://192.168.2.255:80/


Components of URI syntax

a.   Schema: Every URI begins with a scheme name consist of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-"). For example http, https, ftp, telnet represent schemes.

b.   Authority: The authority component is preceded by a double slash ("//") and is terminated by the next slash ("/"), question mark ("?"), or number  sign ("#") character, or by the end of the URI. Authority component can contain port number (it is optional).

c.    Path: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character.

d.   Query: Query component is used to represent query parameters and it is preceded by a question mark(?). Query component is optional.

e.   Fragement: It is an optional component, preceded by a hash (#) symbol. The semantics of a fragment identifier are defined by the set of representations that might result from a retrieval action on the primary resource.

 

You can refer below link to get list of registered uri schemes.

http://www.iana.org/assignments/uri-schemes

 

 

What is URL?

Definition 1: URL stands for Uniform resource locator, it is a special type of uri which tells how to access the resource.

 

Definition 2: URL is used to find the location of a resource in the web. URL is a subset of URIs, in addition to identifying the resource, url provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location").

 

In simple terms, URI is a superset of URLs, a URL is a URI, but a URI not necessarily be a URI.





What is URN?

URN stands for "Uniform Resource Name" is a Uniform Resource Identifier (URI) that uses the urn scheme.

 

Examples

 

urn:isbn:0451450523
urn:ietf:rfc:2648
urn:ISSN:0167-6423

 

URI vs URL vs URN

 


 

Reference

https://datatracker.ietf.org/doc/html/rfc3986

https://datatracker.ietf.org/doc/html/rfc1738

https://datatracker.ietf.org/doc/html/rfc2141

https://datatracker.ietf.org/doc/html/rfc3305

https://en.wikipedia.org/wiki/Uniform_Resource_Name

Previous                                                    Next                                                    Home

No comments:

Post a Comment