问题
I have read many articles about URIs, URLs and URNs, but I don't understand the diff in real examples.
Could you take a few examples of URI and URL?
I think http://stack.com/first/index.html?submit=yes&action=go#second
is URI, not URL, yes?
Then http://stack.com/first/index.html
is URL, because it's not so specific?
Is this image is correct?
回答1:
Here's a quote from the REST in Practice by J.Webber, S.Parastatidis, I.Robinson, that captures the essence of the differences:
URLs and URN s are special forms of URIs.
A URI that identifies the mechanism by which a resource may be accessed is usually referred to as a URL. HTTP URIs are examples of URLs.
If the URI has urn as its scheme and adheres to the requirements of RFC 2141 and RFC 2611, it is a URN. The goal of URN s is to provide globally unique names for resources.
The ISBN of this book is ISBN-13: 978-0596805821, by the way. If you click on the Amazon.com's link Why is ISBN important, you will see the tooltip saying:
This bar-code number lets you verify that you're getting exactly the right version or edition of a book.
This is an example of the URN (and URI by definition) in the urn:isbn
namespace, which does not assume any given mechanism for retrieving this resource, but does identify it.
If you had some link to the book online, for example, in PDF format, that would be a URL (and URI by definition) and look something like this:
https://www.somewebsite.org/books/RestInPractice.pdf
回答2:
No, the image is not correct. Your two examples are both, URIs and URLs.
Every URL is a URI.
Every URN is a URI.
Background
According to W3C’s URIs, URLs, and URNs: Clarifications and Recommendations 1.0 (also published by the IETF as RFC 3305):
In the classical view, a URI is a URL if it specifies the location of a resource, and a URI is a URN if it specifies the name of a resource.
In the contemporary view, making this differentiation is not relevant or useful.
Confusion may arise because the terms "URI" and "URL" are often used synonymously.
Using one term for everything: URI or URL
The Internet Standard for URIs, STD 66 (which currently maps to RFC 3986), recommends:
Future specifications and related documentation should use the general term "URI" rather than the more restrictive terms "URL" and "URN"
WHATWG’s URL Living Standard (and W3C’s version of it) says:
Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone.
My recommendation
- Use "URL" and/or "URI" (or "IRI", if the difference is relevant) for everything.
- Use "URN" only for URIs with the
urn
URI scheme, and only if you need to be specific.
来源:https://stackoverflow.com/questions/42534419/examples-of-uri-url-and-urn