PHPackages                             silverstripe/multi-domain - 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. silverstripe/multi-domain

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

silverstripe/multi-domain
=========================

Allows multiple domains to access one CMS instance, mapping them to different sections of the hierarchy

1.0.0(9y ago)141.6k15[1 issues](https://github.com/silverstripe/multi-domain/issues)BSD-3-ClausePHPCI failing

Since Jan 31Pushed 6y ago12 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

Multi Domains for SilverStripe
==============================

[](#multi-domains-for-silverstripe)

[![Build Status](https://camo.githubusercontent.com/a8a5cbc78b862f46026bb0fd30dbf7fcf9ff7bf5fef5cd0f795f1a813f212b29/68747470733a2f2f7472617669732d63692e6f72672f73696c7665727374726970652f6d756c74692d646f6d61696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/silverstripe/multi-domain) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/06e63d5a339c4db73755a98540911f76543fafea2df5fb69ec7297861e8b312b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696c7665727374726970652f6d756c74692d646f6d61696e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/silverstripe/multi-domain/?branch=master)

Allows multiple domains to access one CMS instance, mapping them to different sections of the hierarchy, which allows for vanity URLs. Examples:

- `example.com` -&gt; resolves to home page
- `example.com/shop/store` -&gt; Resolves to a Store page
- `example-store.com` -&gt; Shows content for `example.com/shop/store`.
- `example-store.com/checkout` -&gt; Shows content for `example.com/shop/store/checkout`

Requirements
------------

[](#requirements)

- silverstripe/framework ^4.0

Configuration
-------------

[](#configuration)

Each domain is identified by a key. You must define one domain using the `primary` key to mark it as the primary domain.

```
---
Name: mymultidomain
After: '#multidomain'
---
SilverStripe\MultiDomain\MultiDomain:
  domains:
    primary:
      hostname: 'example.com'
    store:
      hostname: 'example-store.com'
      resolves_to: 'shop/store'
```

### Options

[](#options)

`allow_subdomains`: If true, domain matching is subdomain agnostic, so that *anything.example.com* still maps to *example.com*, the primary domain in the above configuration.

### Whitelisting

[](#whitelisting)

Sometimes you may have routes that should resolve normally, and bypass the multidomain filter. In this case, for any given domain, you can specify an `allow` list.

```
---
Name: mymultidomain
After: '#multidomain'
---
SilverStripe\MultiDomain\MultiDomain:
  domains:
    primary:
      hostname: 'example.com'
    store:
      hostname: 'example-store.com'
      resolves_to: 'shop/store'
      allow:
        - 'admin/*'
        - 'Security/*'
        - 'my-custom-webhook/'
```

In the above example, any URL beginning with `admin/`, `Security/` or matching `my-custom-webhook/` will resolve on any domain.

### Global whitelists

[](#global-whitelists)

You can put your `allow` node directly under `MultiDomain` to have a global whitelist.

```
---
Name: mymultidomain
After: '#multidomain'
---
SilverStripe\MultiDomain\MultiDomain:
  allow:
    - 'admin/*'
    - 'Security/*'
    - 'my-custom-webhook/'
```

### Forcing URLs to specific domains

[](#forcing-urls-to-specific-domains)

Sometimes, you may have a page that sits outside the node representing a domain, but you still want it to be considered part of that domain. For this, you can use the `force` option.

```
---
Name: mymultidomain
After: '#multidomain'
---
SilverStripe\MultiDomain\MultiDomain:
  domains:
    primary:
      hostname: 'example.com'
    store:
      hostname: 'example-store.com'
      resolves_to: 'shop/store'
      force:
        - 'buy-now/*'
```

In the above configuration, the page `buy-now` can live in the site root, but the URL `example-store.com/buy-now`will nonetheless resolve the page, even though the page isn't under `shop/store`.

Using environment variables
---------------------------

[](#using-environment-variables)

If you have multiple test environments, it may not make sense for you to hard code the host name in the config. Alternatively, you can define an environment variable, i.e. a constant, and refer to it as a string in the config.

```
---
Name: mymultidomain
After: '#multidomain'
Only:
  environment: 'test'
---
SilverStripe\MultiDomain\MultiDomain:
  domains:
    primary:
      hostname: STAGING_PRIMARY_HOSTNAME
    store:
      hostname: STAGING_STORE_HOSTNAME
      resolves_to: 'shop/store'
      force:
        - 'buy-now/*'
```

This way, every environment can declare its hostname independently.

Why not subsites?
-----------------

[](#why-not-subsites)

Subsites creates a parallel CMS instance for a given domain name. This module allows you to map domains to a specific section of the hierarchy, in the context of all your other pages.

Why not "homepage for domain"?
------------------------------

[](#why-not-homepage-for-domain)

That works to create a vanity URL for one page, but as soon as you go deeper into the hierarchy, you return to the native URL. A more robust solution is required for persisting the vanity URLs.

Further, this module is more extensible, allowing for collaboration with other URL-hungry modules, such as Translatable or Fluent.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~1042 days

Total

2

Last Release

2351d ago

### Community

Maintainers

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

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

![](https://www.gravatar.com/avatar/afbb3dcc9ef29c1a6eedd6addcae5fce9ab1271915a85a4c349301b71237368d?d=identicon)[silverstripe-machine01](/maintainers/silverstripe-machine01)

---

Top Contributors

[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (6 commits)")[![robbieaverill](https://avatars.githubusercontent.com/u/5170590?v=4)](https://github.com/robbieaverill "robbieaverill (6 commits)")[![catharsisjelly](https://avatars.githubusercontent.com/u/510747?v=4)](https://github.com/catharsisjelly "catharsisjelly (1 commits)")[![ss23](https://avatars.githubusercontent.com/u/191510?v=4)](https://github.com/ss23 "ss23 (1 commits)")[![threesquared](https://avatars.githubusercontent.com/u/892142?v=4)](https://github.com/threesquared "threesquared (1 commits)")[![micmania1](https://avatars.githubusercontent.com/u/881537?v=4)](https://github.com/micmania1 "micmania1 (1 commits)")[![chillu](https://avatars.githubusercontent.com/u/111025?v=4)](https://github.com/chillu "chillu (1 commits)")

---

Tags

silverstripe

### Embed Badge

![Health badge](/badges/silverstripe-multi-domain/health.svg)

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

PHPackages © 2026

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