I have the following scenario:
- ( I’m using a shared hosting service (namecheap) where I can have several websites from one hosting account (called Addon-Domains). At the same time they also have to be assigned to a subdomain )
- I´ve read the tutorial for multiside-setup for subdomains. But what I need is just is to parse the complete website name and based on that a different /user folder will be used by grav
- so what I want for the users-folder
– www.website1.com ->[…]/users/sites/website1
– www.website2.com ->[…]/users/sites/website2
My setup.php file
<?php
/**
* Multisite setup for subsites accessible via sub-domains.
*/
use Grav\Common\Utils;
// Get domain name
$environment = str_replace("www.", "", $_SERVER['HTTP_HOST']);
#for com-domains
$environment = str_replace(".com", "", $environment );
// Remove port from HTTP_HOST generated $environment
$environment = strtolower(Utils::substrToString($environment, ':'));
$folder = "sites/{$environment}";
# (this is already working!) when browsing e.g. www.website1.com this prints: user/sites/website1/plugins
echo "user/{$folder}/plugins";
return [
'environment' => $environment,
'streams' => [
'schemes' => [
'user' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/{$folder}"],
]
]
]
]
];
My file system
ROOT
TEST
grav-admin
index.php
system
user
sites
website1
accounts
config
data
pages
plugins
themes
website2
accounts
config
data
pages
plugins
themes
setup.php
[...]
The error messaging I’m getting in the browser when browing www.website1.com
Issues Found
Please Review and Resolve before continuing...
Reload Page
/ROOT/TEST/grav-admin/user/data does not exist
/ROOT/TEST/grav-admin/user/pages does not exist
/ROOT/TEST/grav-admin/user/plugins/error does not exist
/ROOT/TEST/grav-admin/user/plugins does not exist
/ROOT/TEST/grav-admin/user/themes does not exist
Notes
- when I’m browsing the website an empty config folder is created in user/sites/
- question: so what I really do not understand is why the präfix for user-stream is not changed
- help is very much appreciated!