Blogs Hub

by AskGif | Nov 28, 2018 | Category :coding

Difference between a URI, a URL, and a URN?

Difference between a URI, a URL, and a URN?

<p>I have seen many people talk about URLs, URIs, and URNs as if they're different things, but they look the same to the naked eye.</p> <p>What are the distinguishable differences between them?</p> <p>&nbsp;</p> <p>From <a title="http://www.ietf.org/rfc/rfc3986.txt" href="http://www.ietf.org/rfc/rfc3986.txt" target="_blank" rel="noopener">http://www.ietf.org/rfc/rfc3986.txt</a></p> <pre class="language-markup"><code>A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location"). The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme [RFC2141], which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.</code></pre> <p>So all URLs are URIs (actually not quite - see below), and all URNs are URIs - but URNs and URLs are different, so you can't say that all URIs are URLs.</p> <p>EDIT: I had previously thought that all URLs are valid URIs, but as per comments:</p> <pre class="language-markup"><code>Not "all URLs are URIs". It depends on the interpretation of the RFC. For example in Java the URI parser does not like [ or ] and that's because the spec says "should not" and not "shall not".</code></pre> <p>So that muddies the waters further, unfortunately.</p>

read more...