7. 区分¶
7.1. URI&URL¶
The main differences are:
- URI identifies a resource, URL provides a location for the resource.
- URI includes URLs as well as URNs (Uniform Resource Names). URL only includes web addresses.
- URL must contain location info like protocol and domain name. URI does not necessarily have that.
- URL is a concrete resource locator, URI can be an abstract identifier.
Some examples to illustrate the differences:
- mailto:user@example.com is a URI but not a URL.
It identifies an email address but does not specify the location.
- ISBN:978-0-306-40615-7 is a URI but not a URL.
It identifies a book but does not tell you where to find it.
- https://www.example.com/users/1 is both a URI and a URL.
It identifies resource with ID 1 and also specifies the location (the domain and path).