📅  最后修改于: 2023-12-03 15:05:46.324000             🧑  作者: Mango
Uniform Resource Identifier (URI) and Uniform Resource Locator (URL) are often used interchangeably, but they are not exactly the same thing. They are both used to identify and locate resources on the internet, but they have some important differences.
A URI is a string of characters that identifies an abstract or physical resource. It is a standardized format for identifying resources with a name, a protocol (such as http, ftp, etc.), and other optional components such as an authority (such as user@host), a port number, and a path. A URI can be used to identify any resource, not just web pages.
The syntax for a URI is as follows:
scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
mailto:john@example.com
tel:+15555555555
urn:isbn:0451450523
A URL is a type of URI that specifies the location of a resource and the protocol used to access it. It can be used to locate web pages, images, videos, and other resources on the internet.
The syntax for a URL is the same as that of a URI, but with some additional components:
scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
http://www.example.com/index.html
ftp://ftp.example.com/documents/document.pdf
In summary, URI is a more general term that includes URLs. URLs are a specific type of URI that identifies the location of a resource on the internet. When you need to identify a resource on the web, you should use a URL, but if you need to identify a resource that is not on the web, you can use a URI.