PHPackages                             primoz2500/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. primoz2500/silverstripe-cdnrewrite

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

primoz2500/silverstripe-cdnrewrite
==================================

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

3.0.0(1y ago)0120BSD-3-ClausePHP

Since Aug 15Pushed 1y agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)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
  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)
- `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, 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)

- 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

27

—

LowBetter than 49% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

635d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c24d7fe3b51d8d53cf25fec8ca65a1e0b3bab8400412e9e128cf0505372147f?d=identicon)[primoz2500](/maintainers/primoz2500)

---

Top Contributors

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

---

Tags

silverstripecdn

### Embed Badge

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

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

###  Alternatives

[silverstripe/multiuser-editing-alert

A module that indicates when people are editing the same page in the CMS

1530.7k1](/packages/silverstripe-multiuser-editing-alert)

PHPackages © 2026

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