Skip to content

Instantly share code, notes, and snippets.

@OleVik
Created May 15, 2016 17:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OleVik/81534efc4394d7feb297acdb16efbfe6 to your computer and use it in GitHub Desktop.
Save OleVik/81534efc4394d7feb297acdb16efbfe6 to your computer and use it in GitHub Desktop.
Grav Multisite Setup, separate pages, config, cache
<?php
/**
* Multisite setup for subsites accessible via sub-domains.
*/
use Grav\Common\Utils;
// Get subsite name from sub-domain
$environment = isset($_SERVER['HTTP_HOST'])
? $_SERVER['HTTP_HOST']
: (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
// Remove port from HTTP_HOST generated $environment
$environment = strtolower(Utils::substrToString($environment, ':'));
$folder = "sites/{$environment}";
if ($environment === 'localhost' || !is_dir(ROOT_DIR . "user/{$folder}")) {
return [];
}
return [
'environment' => $environment,
'streams' => [
'schemes' => [
'user' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/{$folder}"],
]
],
'cache' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/{$folder}/cache"],
]
],
'plugins' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/plugins"],
]
],
'themes' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/themes"],
]
],
'images' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/{$folder}/images"],
]
]
]
]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment