HTTP URI: The Component that Uniquely Identifies Web Resources

·

2 min read

Definition

HTTP URI (Uniform Resource Identifier) is a string used to uniquely identify resources on the internet.

Components

example.com:1030/software?id=test#section-4

SchemeHostPortPathQueryFragment
http://www.example.com:1030/software?id=test#section-4

Scheme

Scheme represents the protocol used to retrieve the resource. Some popular schemes include http, https, ftp, SOAP, etc.

Host

Host represents the domain name or IP address of the server where the resource is located.

Port

Port represents the network port number used for communication with the server. The default port number for the HTTP protocol is 80.

Path

Path represents the directory structure or file name of the resource on the server. The path is separated by slashes (/).

Query

Query is used to pass additional parameters for the resource. The query string starts with a question mark (?) and each parameter consists of a name and a value. Parameters are separated by an ampersand (&).

Fragment

Fragment is used to refer to a specific part of the resource. It starts with a hash symbol (#) and is often used to refer to a specific location or paragraph within a web page.

These URI components enable communication between the client and server in the HTTP protocol and are used to request and retrieve web pages or other resources using web browsers or other HTTP clients.

Example of HTTP URL Components

  1. example.com/index.html

    • Scheme: http

    • Host: www.example.com

    • Port: None, default port 80 is used

    • Path: /index.html

    • Query: None

    • Fragment: None

  2. example.com/search?q=example&lang=en

    • Scheme: https

    • Host: www.example.com

    • Port: None, default port 443 is used

    • Path: /search

    • Query: q=example&lang=en

    • Fragment: None

  3. ftp://ftp.example.com/files/readme.txt#sect..

    • Scheme: ftp

    • Host: ftp.example.com

    • Port: None, default port 21 is used

    • Path: /files/readme.txt

    • Query: None

    • Fragment: section-2

Did you find this article valuable?

Support Eunhan's blog by becoming a sponsor. Any amount is appreciated!