A Uniform Resource Identifier (URI) is a string of characters that uniquely identifies a resource on the internet or a local network. It provides a way to locate or reference a resource, such as a webpage, an image, or a document, using a standardized format.
Two Main Types of URIs:
- Uniform Resource Locator (URL): A URL is a type of URI that not only identifies a resource but also provides the means to locate it, typically indicating the protocol (e.g., HTTP, FTP) and the specific address of the resource.
- Example:
https://www.example.com/index.html
- Example:
- Uniform Resource Name (URN): A URN is a type of URI that uniquely identifies a resource without giving its location or access method. It serves as a persistent identifier for a resource.
- Example:
urn:isbn:0451450523
(Identifies a specific book by its ISBN)
- Example:
Structure of a URI:
A URI typically consists of several components, depending on the type of URI. Here’s a general structure for a URL:
- Scheme: Defines the protocol or method used (e.g.,
http
,ftp
,mailto
). - Authority: Includes the domain name or IP address of the host (e.g.,
www.example.com
). - Path: Specifies the location of the resource on the server (e.g.,
/index.html
). - Query: Contains any additional data or parameters that may be required (e.g.,
?id=123
). - Fragment: A reference to a specific section within the resource (e.g.,
#section2
).
Example:
For the URL https://www.example.com/search?q=uri#results
, the breakdown is:
- Scheme:
https
- Authority:
www.example.com
- Path:
/search
- Query:
q=uri
- Fragment:
#results
URIs are fundamental in the structure of the web and are used to access and refer to resources in a consistent manner.