Skip to content

Commit

Permalink
docs(blog): update url post (#6348)
Browse files Browse the repository at this point in the history
  • Loading branch information
necatiozmen authored Sep 19, 2024
1 parent 6183217 commit f757508
Showing 1 changed file with 68 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-02-01-uri-vs-url
hide_table_of_contents: false
---

**_This article was last updated on January 17, 2024 to provide a more detailed explanation, image and comparison table of URI VS URL._**
**This article was last updated on September 18, 2024, to add sections on the Historical Context of URI and URL, Security Considerations, and SEO Implications of Proper URI and URL Usage.**

## Introduction

Expand All @@ -24,31 +24,24 @@ In this article, you will learn about the concept of a URI, its components, its

Steps we'll cover:

- [What is URI?](#what-is-uri)
- [Components of URI](#components-of-uri)
- [Functions and Architecture of URI](#functions-and-architecture-of-uri)
- [Examples of URI](#examples-of-uri)
- [Syntax Of URI](#syntax-of-uri)
- [Use Case of URI](#use-case-of-uri)
- [What is URL?](#what-is-url)
- [Examples of URLs](#examples-of-urls)
- [Benefits of URI over URL](#benefits-of-uri-over-url)
- [Coding Smarter: Using URI & URL Knowledge in Development](#coding-smarter-using-uri--url-knowledge-in-development)
- [Comparison Summary of URL and URI](#comparison-summary-of-url-and-uri)
- [Examples of URLs](#examples-of-urls)
- [Benefits of URI over URL](#benefits-of-uri-over-url)
- [Coding Smarter: Using URI \& URL Knowledge in Development](#coding-smarter-using-uri--url-knowledge-in-development)
- [Security Considerations for Using URLs and URIs](#security-considerations-for-using-urls-and-uris)
- [Comparison Summary of URL and URI](#comparison-summary-of-url-and-uri)
- [Bonus: SEO Benefits of Proper URI and URL Usage](#bonus-seo-benefits-of-proper-uri-and-url-usage)
- [Conclusion](#conclusion)

## What is URI?

URI is an abbreviation for "Uniform Resource Identifier," which refers to a unique identifier composed of a string of characters that points to any resource on the internet via procedures such as name, location, or both.
Back in the late 1980s, Tim Berners-Lee, the inventor of the World Wide Web, introduced the concept of the URI (Uniform Resource Identifier). His goal was to create a universal system to locate and access web resources, from web pages to files, using a unique identifier. URIs were designed to identify any resource on the web, whether by name, location, or both.

URLs and URNs are the two types of URIs. URLs, a type of URI, stand for Uniform Resource Locators and are commonly known as website addresses, illustrating a key aspect of the difference between URI and URL. They specify the location of a resource on the Internet and instruct a web browser on how to retrieve it.
URLs (Uniform Resource Locators), a specific type of URI, focus on the "location" aspect—where a resource can be found on the web and how to retrieve it. For instance, the URI "https://www.mywebsite.com" specifies the location of a website and instructs a web browser to retrieve it using the HTTPS protocol. This makes URLs crucial for pinpointing resources by their address, while URIs, in general, can identify resources without necessarily specifying how to locate them.

For example, the URI "https://www.mywebsite.com" specifies the location of a website and instructs a web browser to retrieve it using the HTTPS protocol.
Web protocols like HTTP and HTTPS rely on URIs to communicate with resources on the internet. The architecture of a URI is a string of characters that represent a web resource's address, often combining the resource’s name and location.

Web protocols such as HTTP and HTTPS use URIs to communicate with multiple resources on the internet. The architecture of URIs is a string of characters that represents the address of a web resource, which is usually a combination of the resource's name and address. This distinction is crucial in understanding what is a URI and how it functions in contrast to a URL

In essence, a URI can identify any type of resource, including web pages, images, videos, and other types of files. They are an essential component of how the Internet works and are used in various contexts, including web addresses, links, and other types of references to online resources.

Understanding what a URI is, including URI examples, is fundamental in grasping the URI vs URL concept
In essence, URIs are a broad concept for identifying resources on the internet, and URLs are a more specific type of URI focused on location. While these terms are often used interchangeably, this historical context helps clarify why URLs are just one way of identifying resources within the broader URI framework.

## Components of URI

Expand Down Expand Up @@ -195,6 +188,39 @@ URIs (Uniform Resource Identifiers) are a broader classification of identifiers
4. **Routing in Web Applications**: URLs are integral in routing within web applications. Frameworks like React or Angular use URLs to determine which component to render, for example, `https://mywebsite.com/about` might route to an About page.
5. **Link Generation**: In content management systems, URLs are dynamically generated to link to various content pieces. A blog post might be accessible through a URL like `https://blog.mywebsite.com/2024/01/my-first-post`, which is automatically generated based on the post's title and date.

## Security Considerations for Using URLs and URIs

I wanted to share a quick note on some important **security considerations** when working with URLs and URIs, especially since we use them all the time.

**Exposing Sensitive Data**
URLs can expose sensitive information like user IDs or session tokens, especially if they're passed in the query string. This can be dangerous if someone captures the URL.

It’s better to avoid passing sensitive data in the URL and use POST requests instead. Also, always use HTTPS to encrypt the data.

**Phishing and Spoofing**
Attackers can create fake URLs that look like real ones (for example, "g00gle.com" instead of "google.com"). Users might click these without noticing the difference.

Make sure we validate URLs properly and teach users to check links before clicking.

**Open Redirects**
Sometimes URLs can allow users to be redirected to another website, which can be exploited for phishing.

Always check and limit where redirects can send users.

**Cross-Site Scripting (XSS)**
If a URL includes unsanitized user input, attackers could inject malicious scripts into our web pages.

Always sanitize input and encode URL parameters to block script injections.

**Session Hijacking**
Passing session tokens or login info in a URL can be risky because they can be logged or shared accidentally.

It’s safer to use cookies for session management and secure them with HTTP-only and secure flags.

**Using HTTPS**
Always ensure that any sensitive data is sent over HTTPS to keep it encrypted and safe from attackers.
**What we can do:** Double-check that all critical pages use HTTPS, especially when handling personal data.

## Comparison Summary of URL and URI

| URL | URI |
Expand All @@ -221,6 +247,28 @@ Below you can find a comparison table summarizing both the similarities and diff
| Mutability | Generally mutable and can change over time. | Can be either mutable or immutable, depending on whether it's a URL or a URN. |
| Similarity | All URLs are URIs. | Includes URLs as a subset. |

# Conclusion
## Bonus: SEO Benefits of Proper URI and URL Usage

I just wanted to share some quick thoughts on how using **URIs and URLs** the right way can improve **SEO** on our website. Here are the key points to consider:

**Clean and Descriptive URLs**
Search engines like Google give more preference to URLs that are readable and include target keywords. For example, “**/blog/seo-best-practices**” is much better than “**/blog/id123?ref=xyz**.” Clean URLs make it easier for both users and search engines to understand what the page is about.

**Structural Consistency**
Keeping a consistent URL structure across the website helps with crawlability, allowing search engines to index pages correctly. For example, using a pattern like “**/category/post-name**” creates a clear structure for the content hierarchy.

**Avoiding Duplicates with Canonical URLs**
When we have multiple URLs pointing to the same content (common with tracking parameters), we can use **canonical tags** to tell search engines which one should be considered the main URL. This helps avoid duplicate content issues, which can negatively impact rankings.

**Use Hyphens, Not Underscores**
Hyphens in URLs (like **/web-design-tips**) are better for SEO than underscores (like **/web_design_tips**) because search engines treat hyphens as spaces between words, making the URL more readable.

**Short, Keyword-Rich URLs**
URLs should be short and include important keywords without overstuffing. Shorter URLs tend to rank better because they’re easier to remember and share.

**HTTPS for Better Ranking**
Search engines prioritize websites using HTTPS over HTTP, so using secure URLs not only improves security but also helps with SEO ranking.

## Conclusion

In summary, when considering URI vs URL, URIs are more versatile and flexible than URLs. They are designed to be more persistent and interoperable. URIs are more general-purpose identifiers that can identify any type of resource, whereas URLs are limited to identifying a resource's location on the Internet.

0 comments on commit f757508

Please sign in to comment.