Uniform Resource Locator - Notes By ShariqSP
Understanding URLs
A URL (Uniform Resource Locator) is the address used to access resources on the web. It is a fundamental component of the internet, allowing users and browsers to locate web pages, images, videos, and other resources.
Components of a URL
- Scheme: Specifies the protocol used, such as
http
orhttps
. - Domain: Indicates the website's domain name, like
example.com
. - Port: (Optional) A number after the domain that specifies a port, e.g.,
:8080
. - Path: The file or page location on the server, e.g.,
/about-us
. - Query String: (Optional) Provides additional parameters, starting with
?
, e.g.,?id=123
. - Fragment: (Optional) A section within a page, indicated by
#
, e.g.,#contact
.
Example of a Complete URL
https://example.com:8080/about-us?user=admin#section1
Explanation:
In the example above:
- Scheme:
https
(secure HTTP) - Domain:
example.com
- Port:
8080
- Path:
/about-us
- Query String:
?user=admin
- Fragment:
#section1
Understanding URLs: A Beginner's Guide
A URL (Uniform Resource Locator) is like a street address for the internet. Just like you need an address to find someone's house, you need a URL to find a specific webpage, image, video, or any other resource on the web.
For example, if you want to visit Google's website, you enter https://www.google.com
in your browser's address bar. This is a URL that takes you directly to Google's homepage.
Breaking Down a URL
A URL has different parts, each with a specific purpose. Let's explore them one by one:
1. Scheme (Protocol)
- What it is: The scheme tells your browser how to connect to the website. The most common schemes are:
http
(Hypertext Transfer Protocol): Used for most websites.https
(Secure Hypertext Transfer Protocol): A secure version of HTTP that encrypts the data sent between your browser and the website.
- Examples:
http://example.com
- Not secure.https://example.com
- Secure.
2. Domain Name
- What it is: The domain name is the name of the website you want to visit. It represents the server's address on the internet.
- Parts of a Domain:
- Top-Level Domain (TLD): The last part like
.com
,.org
,.net
. - Second-Level Domain: The name you see just before the TLD, like
google
ingoogle.com
.
- Top-Level Domain (TLD): The last part like
- Examples:
www.example.com
,www.facebook.com
,www.wikipedia.org
3. Port Number (Optional)
- What it is: A port is like a door on a server used for different types of connections.
- Common Ports:
80
for HTTP (usually hidden)443
for HTTPS (usually hidden)8080
for other custom connections
- Example with Port:
https://example.com:8080
4. Path
- What it is: The path directs you to a specific page or file on the website. It's like the section of a book.
- Examples:
/about-us
,/blog/post1
5. Query String (Optional)
- What it is: The query string helps you send extra information to the website, often used in search forms, filters, or tracking.
- How it looks: Starts with a
?
followed by key-value pairs separated by&
. - Examples:
?query=books
,?category=electronics&sort=price
6. Fragment (Optional)
- What it is: The fragment is like a bookmark inside a book. It directs you to a specific section within a page.
- How it looks: Starts with a
#
. - Examples:
#team
,#comments
Putting It All Together: A Complete URL Example
Here’s a complete URL example broken down:
Part | Explanation | Example |
---|---|---|
Scheme | Secure connection | https |
Domain | Website name | www.example.com |
Port | Specific server door (optional) | 8080 |
Path | Location of the page | /products/view |
Query String | Extra information | ?id=123&category=shoes |
Fragment | Specific section on the page | #reviews |
How Do URLs Work?
- Typing the URL: You type a URL like
https://www.example.com
in your browser's address bar. - DNS Lookup: Your browser sends a request to a DNS server to find the IP address of the domain.
- Connecting to the Server: Your browser connects to the website's server.
- Request and Response: Your browser requests the webpage, and the server sends it back.
- Displaying the Page: Your browser displays the content of the page.
Common Uses of URLs
- Accessing Websites: Enter URLs in the browser to visit websites.
- Downloading Files: URLs can link directly to files like PDFs, images, or videos.
- APIs: URLs are used to interact with web APIs, where data can be fetched or sent.
- Tracking: URLs often have tracking codes to monitor clicks, especially in marketing.
Quick URL Glossary
- DNS (Domain Name System): Converts domain names into IP addresses.
- IP Address: A unique set of numbers identifying a server.
- HTTP/HTTPS: Protocols for data transfer over the web.
- 404 Error: A code that means the page you’re looking for cannot be found.