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. [File &amp; Storage](/categories/file-storage)
4. /
5. swordfox/silverstripe-cdnrewrite-plus

ActiveSilverstripe-vendormodule[File &amp; Storage](/categories/file-storage)

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

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

6.0.1(6mo ago)0512BSD-3-ClausePHP

Since Jun 6Pushed 6mo 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 2d 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

36

—

LowBetter than 79% of packages

Maintenance66

Regular maintenance activity

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

208d ago

Major Versions

1.0.1 → 6.0.12025-12-08

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/549500?v=4)[Swordfox](/maintainers/swordfox)[@swordfox](https://github.com/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

[uploadcare/uploadcare-php

Uploadcare PHP integration handles uploads and further operations with files by wrapping Upload and REST APIs.

1052.7M7](/packages/uploadcare-uploadcare-php)[deliciousbrains/wp-amazon-s3-and-cloudfront

Automatically copies media uploads to a storage provider's bucket for delivery. Optionally configure a CDN for even faster delivery.

312214.5k1](/packages/deliciousbrains-wp-amazon-s3-and-cloudfront)[vinelab/cdn

Content Delivery Network (CDN) Package for Laravel

217244.0k1](/packages/vinelab-cdn)[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

157234.9k](/packages/publiux-laravelcdn)[bummzack/sortablefile

An extension for SilverStripe that adds sorting to UploadField.

67688.3k58](/packages/bummzack-sortablefile)[arubacao/asset-cdn

Serve Laravel Assets from a Content Delivery Network (CDN)

110191.8k](/packages/arubacao-asset-cdn)

PHPackages © 2026

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