The multisite feature lets you manage multiple websites from a single October CMS installation and assign content dependent on the domain name. For example, an e-commerce store with different country-specific sub-sites. You can also use it to manage translations for a localized website.
You can create sites by visiting the admin panel's Settings → Manage Sites page. Every installation includes a primary site that acts as the default site for every request.
The following configuration defines each site:
*.mydomain.tld.When you create more than one site, each can be selected in the admin panel using the site selection dropdown menu.
The sitePicker component lets you manage links to other sites. The best place to include this is in your page or layout template.
[sitePicker]{% set availableSites = sitePicker.sites %}View the Site Picker component article to learn how to display site URLs and generating alternative page links.
October CMS is configured to automatically detect a matching site based on the browser's preferred language when the following conditions are met.
For example, if the primary site is English with a route prefix of /en and another site French has a prefix of /fr then the following behavior can be observed.
| Base URL | Behavior |
|---|---|
https://yoursite.tld/en | Displays the English site |
https://yoursite.tld/fr | Displays the French site |
https://yoursite.tld | Redirect based on language preference |
When the user visits the base URL, their preferred language is automatically detected and will be redirected to a matching site. The matching site is based on its locale value and if no match is found then the primary site is used.
You can modify this behavior using the
redirect_policyvalue found in the config/cms.php file.
In its initial state, multisite is helpful in creating multiple websites in a single language, or a single website using multiple languages. Grouping sites allow you to extend this concept further to create multiple sites with multiple languages. Create site groups by navigating to Settings → Manage Sites → Manage Site Groups, and once a group is created, a group selection field should appear for each site.
In practical terms, each site group represents a website and site definitions belonging to the group represent the site in an alternative language. The following example shows a grouped site configuration for a website about cats and dogs with two languages for each.
| Site Group | Site Name |
|---|---|
| Dogs | English |
| Dogs | French |
| Cats | English |
| Cats | French |
Grouped sites will only replicate fields within their specific group. For example, if a Tailor blueprint uses the multisite: sync option, the records will only synchronize across sites in the same group.
Site definitions can restrict their visibility based on the administrator role, which allows you to use dedicated administrator roles to manage a specific sites. To enable the multisite role restrictions feature:
When enabled, the site will only be visible in the backend panel to administrators that are specified in the field. For example, to create a site that is only accessible to Developers, select the Developer role in the field.
There are some core features that are not multisite-enabled by default, such as the mail configuration. You may selectively enable multisite features using the config/multisite.php file found under the features section. The following feature keys are available to use with multiple site definitions.
| Feature | Description |
|---|---|
cms_maintenance_setting | Maintenance Mode Settings are unique for each site |
backend_mail_setting | Mail Settings are unique for each site |
system_asset_combiner | Asset combiner cache keys are unique to the site |
You may disable the multisite features entirely by setting the enabled configuration to a false value.
'enabled' => falseThe site service includes the global Site facade that provides tools for working with multisite. For example, the following code locates a model in the context of the site with ID 2.
$model = Site::withContext(2, function() {
return Model::find(1);
});Read the Site Service article to learn more.