Redirecting & Rewriting URLs
Discover how to redirect network requests to different URLs or rewrite parts of URLs based on defined criteria.
Intro to URL Magic
Welcome! In this lesson, we'll learn how browser extensions can change where network requests go or how their URLs look.
- Redirecting sends a request to a completely different URL.
- Rewriting modifies parts of the original URL before it's processed.
Both are powerful tools for controlling web traffic using the `declarativeNetRequest` API.
Why Redirect or Rewrite?
Modifying URLs can serve many useful purposes:
- Enforce HTTPS: Automatically upgrade insecure HTTP connections.
- Fix broken links: Redirect old URLs to new ones.
- Clean up URLs: Remove unnecessary tracking parameters.
- Block unwanted content: Redirect specific requests to an empty page.
It helps improve security, privacy, and user experience.
All lessons in this course
- Blocking Network Requests
- Modifying Request Headers
- Redirecting & Rewriting URLs
- Dynamic Rules & Debugging declarativeNetRequest