In the context of the World Wide Web, a URL (Uniform Resource Locator) is a string of characters that specifies the location of a resource, such as a web page, on the internet. A URL typically consists of three parts: the scheme, the hostname, and the path. For example, in the URL https://www.example.com/page.html
, https
is the scheme, www.example.com
is the hostname, and /page.html
is the path.
A URI (Uniform Resource Identifier) is a string of characters that identifies a name or a resource. A URI can be either a URL or a URN (Uniform Resource Name). A URN is a type of URI that identifies a resource by name, rather than by location.
For example, the following is a URL:
https://www.example.com/page.html
The following is a URN:
urn:isbn:0451450523
Both the URL and the URN are examples of URIs, but they serve different purposes. A URL specifies the location of a resource on the internet, while a URN identifies a resource by name.
In general, URLs are used to access resources on the internet, while URNs are used to identify resources that may or may not be available on the internet. URNs can be used to identify resources that are not available online, such as books or physical objects, or to identify resources that are available online but do not have a fixed location, such as web services or databases.