PHPackages                             swordfox/silverstripe-cdnrewrite-plus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. swordfox/silverstripe-cdnrewrite-plus

ActiveSilverstripe-vendormodule

swordfox/silverstripe-cdnrewrite-plus
=====================================

Automatically rewrites the URLs of media and assets to use a CDN

6.0.1(5mo ago)0301BSD-3-ClausePHP

Since Jun 6Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/swordfox/silverstripe-cdnrewrite-plus)[ Packagist](https://packagist.org/packages/swordfox/silverstripe-cdnrewrite-plus)[ Docs](https://github.com/swordfox/silverstripe-cdnrewrite-plus)[ RSS](/packages/swordfox-silverstripe-cdnrewrite-plus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Silverstripe CDN Rewrite Plus
=============================

[](#silverstripe-cdn-rewrite-plus)

Provides a simple method of rewriting the URLs of assets and resources to allow the use of a subdomain or external CDN service

See the configuration notes below for an example of how to set this module up.

Requirements
============

[](#requirements)

- Silverstripe 6.x
- Silverstripe 5.x
- Silverstripe 4.x

Installation
============

[](#installation)

- Install the code with `composer require swordfox/silverstripe-cdnrewrite-plus "^1"`
- Run a `dev/build?flush` to update your project

Usage
=====

[](#usage)

The module won't make any changes to your site unless you do a bit of configuration. There are a few options you can set, done in a yml file:

```
---
Name: cdnconfig
---

Swordfox\CDNRewritePlus\CDNMiddleware:
  cdn_rewrite: true
  cdn_domain: 'https://cdn.example.com'
  add_debug_headers: true
  enable_in_dev: true
  subdirectory: ''
  add_prefetch: true
  rewritelinks: true
  rewritebgattr: true
  assetprefix: 'site-'
  rewrites:
    - 'assets'
    - 'site-resources'
```

The options are hopefully fairly self explanatory:

- `cdn_rewrite` - globally enables and disables the module (default false - disabled)
- `cdn_domain` - the full domain name of the CDN (required to enable module)
- `add_debug_headers` - if enabled, adds extra HTML headers to show the various operations being applied (default false)
- `enable_in_dev` - enable the CDN in dev mode (default false)
- `subdirectory` - set this if your site is in a subdirectory (eg. for  - set this to 'silverstripe')
- `add_prefetch` - set this to true if you want the module to automatically add a `` tag to your html head to improve performance
- `rewritelinks` - set this to false if your CDN does not support all file types e.g. PDFs
- `rewritebgattr` - rewrites background-image: url() paths
- `assetprefix` - adds a prefix to the assets directory for use on shared CDNS e.g. `https://cdn.example.com/site-assets/image.jpg`
- `rewrites` - this is a list of the prefixes you wish to rewrite. By default, CMS 4 exposes content in a \_resources directory in the public structure, so you'll probably want that as a minimum. You can add as many additional entires here as required.

Notes
=====

[](#notes)

- The module is disabled in the CMS / admin system, so rewrites do not currently happen here
- When enabled, the module will always add an HTTP header of `X-CDN: Enabled` to show that it's working, even if none of the other rewrite operations are carried out. If this is not present and you think it should be, ensure that you have set `cdn_rewrite` to true, that you have specified the `cdn_domain` in your config file and that you have `enable_in_dev` set to true if you are testing in dev mode.

Credits
=======

[](#credits)

- Complete copy of [DorsetDigital's silverstripe-cdnrewrite](https://github.com/DorsetDigital/silverstripe-cdnrewrite) with a few extra options.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~275 days

Total

3

Last Release

152d ago

Major Versions

1.0.1 → 6.0.12025-12-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/96b760811dd50cc818deef02183cfabd8efacbc8f27af1c5f1fcde738980d2dd?d=identicon)[swordfox](/maintainers/swordfox)

---

Top Contributors

[![swordfox](https://avatars.githubusercontent.com/u/549500?v=4)](https://github.com/swordfox "swordfox (4 commits)")

---

Tags

silverstripecdn

### Embed Badge

![Health badge](/badges/swordfox-silverstripe-cdnrewrite-plus/health.svg)

```
[![Health](https://phpackages.com/badges/swordfox-silverstripe-cdnrewrite-plus/health.svg)](https://phpackages.com/packages/swordfox-silverstripe-cdnrewrite-plus)
```

###  Alternatives

[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)[markguinn/silverstripe-cloudassets

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

209.2k2](/packages/markguinn-silverstripe-cloudassets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
