PHPackages                             dorsetdigital/silverstripe-cdnrewrite - 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. dorsetdigital/silverstripe-cdnrewrite

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

dorsetdigital/silverstripe-cdnrewrite
=====================================

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

v2.2.0(5mo ago)810.5k6BSD-3-ClausePHP

Since May 22Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/DorsetDigital/silverstripe-cdnrewrite)[ Packagist](https://packagist.org/packages/dorsetdigital/silverstripe-cdnrewrite)[ Docs](https://github.com/DorsetDigital/silverstripe-cdnrewrite)[ RSS](/packages/dorsetdigital-silverstripe-cdnrewrite/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

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

[](#silverstripe-cdn-rewrite)

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

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1a2d04d04b7c890f535fce220f3af9a2f7230cccaa53ea538381c9080340bb41/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f446f727365744469676974616c2f73696c7665727374726970652d63646e726577726974652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DorsetDigital/silverstripe-cdnrewrite/?branch=master)[![Build Status](https://camo.githubusercontent.com/b7d62d01994dce563b65105b521e291519e7cdb03aa49de0cbc931b63cfd4148/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f446f727365744469676974616c2f73696c7665727374726970652d63646e726577726974652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DorsetDigital/silverstripe-cdnrewrite/build-status/master)[![License](https://camo.githubusercontent.com/b3775a2de17853a90995faa104f941eef3ad3c40cc89e34b8b1eaea014614d4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d425344253230332d2d436c617573652d626c75652e737667)](LICENSE.md)[![Version](https://camo.githubusercontent.com/3bc8c935603c7e7dd15282593cfeb1a3f8b74a4333781715b8947cd859912d53/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f727365746469676974616c2f73696c7665727374726970652d63646e726577726974652e7376673f7374796c653d666c6174)](https://packagist.org/packages/dorsetdigital/silverstripe-cdnrewrite)

V2
==

[](#v2)

Please note, the V2 branch introduces a new configuration syntax. If you are using V1 of the module, you will need to change this before it will work correctly. See the configuration notes below for an example of how to set this module up.

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

[](#requirements)

\*Silverstripe 4.x

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

[](#installation)

- Install the code with `composer require dorsetdigital/silverstripe-cdnrewrite "^2"`
- 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
---

DorsetDigital\CDNRewrite\CDNMiddleware:
  cdn_rewrite: true
  cdn_domain: 'https://cdn.example.com'
  add_debug_headers: true
  enable_in_dev: true
  enable_in_preview: false
  subdirectory: ''
  add_prefetch: true
  rewrites:
    - '_resources'
    - 'client'
```

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)
- `enable_in_preview` - enable the rewrites in the CMS preview panel (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
- `rewrites` - this is a list of the prefixes you wish to rewrite. By default, the CMS 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 unless explicitly enabled with the setting above, 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.
- Extension points are provided in the middleware to allow you to override the search patterns and replacemnts. See the source code for details. (Beware - this can break your site!)

Need help?
==========

[](#need-help)

- [Open an issue](https://github.com/DorsetDigital/silverstripe-cdnrewrite/issues) on the repository
- Ask in the [community Slack channel](https://silverstripe-users.slack.com/)
- See you at the next [StripeCon](https://stripecon.eu)!

Credits
=======

[](#credits)

- Very much inspired by [Werner Krauss' silverstripe-cdnrewrite](https://github.com/wernerkrauss/silverstripe-cdnrewrite)
- As always, thanks to the core team for all their hard work.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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 ~279 days

Recently: every ~569 days

Total

11

Last Release

177d ago

Major Versions

v1.1.2 → v2.02019-10-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee91a8692650ac93cf817af52118adff8e11bf18866964f492f3e434e4f33f35?d=identicon)[DorsetDigital](/maintainers/DorsetDigital)

---

Top Contributors

[![DorsetDigital](https://avatars.githubusercontent.com/u/15108750?v=4)](https://github.com/DorsetDigital "DorsetDigital (26 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

cdncdn-supportsilverstripesilverstripe-4silverstripe-modulesilverstripecdn

### Embed Badge

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

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

###  Alternatives

[unclecheese/silverstripe-kickassets

Provides an alternative file management interface for SilverStripe CMS with drag-and-drop, multi-selection, and several other desktop-like UI conventions.

4628.3k1](/packages/unclecheese-silverstripe-kickassets)[markguinn/silverstripe-cloudassets

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

199.2k2](/packages/markguinn-silverstripe-cloudassets)[unclecheese/kickassets

Provides an alternative file management interface for SilverStripe CMS with drag-and-drop, multi-selection, and several other desktop-like UI conventions.

464.0k](/packages/unclecheese-kickassets)[sunnysideup/ecommerce

Silverstripe E-commerce Application

247.3k84](/packages/sunnysideup-ecommerce)

PHPackages © 2026

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