# CDN Rewrite for WordPress

> Serve images, CSS and JavaScript from a CDN or pull zone by rewriting their URLs on the front end. Part of Toggleworks, one plugin for the whole site.

TW-PRF-02 Performance


Serve images, CSS and JavaScript from a CDN or pull zone by rewriting their URLs on the front end.

[Get it from $26 a year](https://togglework.app/pricing/#plans) [Try it in the demo](https://togglework.app/demo/)

CDN Rewrite

**Part number**
: TW-PRF-02
**Section**
: [Performance](https://togglework.app/features/performance/)
**Settings**
: 6 (2 on/off)
**Starts**
: Switched off
**In plans**
: Every plan

## Why it matters

A CDN serves your images, CSS and JavaScript from servers close to each visitor and takes that load off your host. With a “pull zone” CDN, all WordPress needs to do is point file addresses at the CDN.

### What it does

- Rewrites file URLs to your CDN host on the front end; paths stay the same.
- Covers wp-content and wp-includes by default, including post content and featured images.
- Exclusions by extension or URL fragment; PHP files are never rewritten.
- Adds a preconnect hint for the CDN host.

![CDN Rewrite settings screen in the Toggleworks WordPress plugin, showing CDN URL, Directories to rewrite, Excluded file extensions, Excluded URLs](https://togglework.app/wp-content/themes/toggleworks-site/assets/img/parts/performance-cdn-rewrite.webp?v=1795524208)

The CDN Rewrite screen in wp-admin, where you switch it on and change its settings.

## Set it up

1. Create a pull zone at your CDN that pulls from this site.
2. Paste the CDN address and check a page: image and CSS URLs should now use it.

## What you can set

Switch CDN Rewrite on in Toggleworks → Performance, then adjust any of these. Each one starts with a default, so you can switch the part on first and fine-tune later.

- CDN URL
- Directories to rewrite
- Excluded file extensions
- Excluded URLs
- Rewrite URLs inside post content, featured images and block widgets
- Add a preconnect hint for the CDN host

## Good to know

- If fonts break, your CDN needs to send CORS headers for font files.
- Proxy CDNs like Cloudflare in front of the whole site don’t need URL rewriting.

## One less plugin to install

CDN Rewrite does a job people often install a separate plugin for:

- Serving files from a CDNOften done with WP Rocket
- A CDN address for static filesOften done with Perfmatters

## Comes with 187 more parts

CDN Rewrite is one part of Toggleworks, a single plugin for security, speed, SEO, backups, email and store tools. Switch on what your site needs; the rest stays off and loads nothing.

[All 18 Performance parts](https://togglework.app/features/performance/)

### People also look for it as

- cdn
- pull zone
- bunny
- cloudfront
- keycdn
- static
- assets
- url rewrite

## Often switched on with it

- [AI Content Refresh](https://togglework.app/features/ai/content-refresh/) — TW-AI-11 · Finds older posts that need updating and drafts a refreshed version — current facts, clearer wording, same voice — for you to… · 5 settings
- [Asset Manager](https://togglework.app/features/performance/asset-manager/) — TW-PRF-01 · See every CSS and JavaScript file a page loads and switch off the ones it does not need — on one page, everywhere, or everywhere… · Own screen in wp-admin
- [Browser Cache Headers](https://togglework.app/features/performance/page-cache-headers/) — TW-PRF-14 · Let browsers and proxies cache pages for logged-out visitors, and optionally strip ?ver= from asset URLs. · 2 settings
- [Bulk WebP Converter](https://togglework.app/features/performance/webp-converter/) — TW-PRF-18 · Convert your existing media library to WebP in the background and serve the smaller files automatically. Originals are kept, so… · 3 settings
- [Critical CSS](https://togglework.app/features/performance/critical-css/) — TW-PRF-03 · Inlines only the CSS needed for the top of each page and loads the rest without blocking — fixing the “eliminate render-blocking… · 5 settings
- [Database Cleanup](https://togglework.app/features/performance/db-cleanup/) — TW-PRF-04 · Remove old revisions, auto-drafts, trash, spam, orphaned meta and expired transients, by hand or on a weekly schedule. · 3 settings

## Questions

**Is CDN Rewrite included in every Toggleworks plan?**

Yes. Every plan includes all 188 parts, CDN Rewrite among them. Plans differ only in how many sites you can use them on, and staging or local copies of a site don’t count.

**Does CDN Rewrite slow my site down when it’s switched off?**

No. Every part starts switched off, and a part that is off loads none of its code. Switch on CDN Rewrite only if your site needs it.

**What if a setting locks me out?**

Add `define( 'TOGGLEWORKS_SAFE_MODE', true );` to wp-config.php. It pauses every part until you remove the line, and Tools → Recent changes lets you undo a change.

**Can I try CDN Rewrite before I buy?**

Yes. The [live demo](https://togglework.app/demo/) runs a WordPress site with Toggleworks in your browser, and every plan has a 14-day refund.

## Switch off the plugin pile.

All 188 parts, one license, updates and support. 14-day refund.

[Choose a plan](https://togglework.app/pricing/#plans) [Try the live demo](https://togglework.app/demo/)

---

Source: https://togglework.app/features/performance/cdn-rewrite/
