Uniform Resource Identifier(URI)⚓︎
In web development we always say
endpoints. The concept refers toURI+HTTP request method(GET, POST, etc.). So what isURI, what is the difference betweenURIandURL?
Definition⚓︎
What is URI and URL
-
URI: Uniform Resource Identifier. -
URL: Uniform Resource Locator.
Difference⚓︎
Difference between URI and URL?
URIidentifies a resource and differentiates it from others by using a name, location, or both.URLidentifies the web address or location of a unique resource.
Syntax⚓︎
Syntax of URI/URL
scheme:[//authority]path[?query][#fragment]
The first component of a URI defines the addressing system:
- in some cases, it is a protocol used to access a resource.
- meanwhile, other techniques may NOT specify any protocol.
Scheme can contain any combination of letters, digits, plus signs, periods, or hyphens followed by a colon. The most common URI schemes include HTTP, HTTPS, FTP, mailto, and file.
HTTP, HTTPS, and FTP
HTTP(Hypertext transfer protocol) – allows users to access data from web pages using hypertext links.HTTPS(Hypertext transfer protocol secure) – protects data transmission between the user’s browser and site.FTP(File transfer protocol) – used for a file transfer between different devices via a network.
e.g. file:website.com/pathtofile/intro.pdf
An optional component preceded by a double slash and terminated by a slash, a question mark, or a hash symbol. It consists of three sub-components:
- Userinfo – includes a
usernameand apasswordseparated by a colon. - Host – consists of either an
IP addressor aregistered name. The IP address should be inserted into brackets. - Port – a
protocolused for connecting the server. It is an optional sub-component followed by a colon.
e.g. file:(//)website.com/pathtofile/intro.pdf
The thrid component contains a sequence of data segments that describes the location of a resource in a directory structure. It should be empty or separated by a slash.
e.g. telnet://192.0.2.16:80/ (valid URI with an empty path)
e.g. foo://info.example.com ?fred (valid URI with an empty path)
e.g. file:(//)website.com/pathtofile/intro.pdf
A component that contains a query string of non-hierarchical data. It is often a string of key=value pairs. This component is preceded by a question mark.
e.g. https://example.org/test/test1?search=test-question#part2
This optional component includes a fragment identifier that provides the direction to a secondary resource. A fragment is preceded by a hash symbol and terminated by the end of a URI.
e.g. https://example.org/test/test1?search=test-question#part2