What are the differences between URI, URL and URN
Difference Between URI, URL, and URN
URI
URI (Uniform Resource Identifier): A URI is a generic term used to identify a resource, either by its name, location, or both. It is an umbrella term that includes both URLs and URNs.
Examples:
https://example.com/resource
(a URL, as it specifies the resource’s location)urn:isbn:978-3-16-148410-0
(a URN, as it names the resource without specifying a location)
URL
URL (Uniform Resource Locator): A URL is a type of URI that specifies the location of a resource on the internet and the protocol to access it.
Components of a URL:
- Protocol: The scheme (e.g.,
http
,https
,ftp
). - Domain Name/Address: The location of the resource (e.g.,
example.com
). - Path: The specific resource (e.g.,
/resource/page
). - Query Parameters (Optional): Extra details (e.g.,
?id=123
).
Example: https://www.example.com/index.html
URN
URN (Uniform Resource Name): A URN is a type of URI that names a resource uniquely but does not describe how to locate or access it.
Example: urn:isbn:978-3-16-148410-0
Key Differences
Aspect | URI | URL | URN |
---|---|---|---|
Definition | General identifier of a resource | Specifies the location and access method | Names a resource uniquely without location |
Type | Umbrella term that includes URL and URN | A subset of URI | A subset of URI |
Purpose | Identifies a resource | Locates and accesses a resource | Names a resource persistently |
Examples | https://example.com , urn:isbn:... |
https://example.com |
urn:isbn:978-3-16-148410-0 |