Multi site and Custom folder setup not working

I have made this multi site and custom folder setup and got everything working except when I try to access the panel, it then can’t find the media folder.

This is my folder structure:

root
 |-- domains
 |    |-- domain_1
 |    |    |-- content
 |    |    |-- media
 |    | 
 |    |-- domain_2
 |
 |-- kirby
 |-- public (web root folder)
 |    |-- assets
 |    |-- index.php   
 |
 |-- site

My web server points to the root/public folder, and this is my root/public/index.php file:

<?php
include dirname(__DIR__) . '/kirby/bootstrap.php';

$sites = [
  'local.domain_1' => dirname(__DIR__) . '/domains/domain_1',
  'local.domain_2' => dirname(__DIR__) . '/domains/domain_2',
];

$url  = Url::host();
$domainRoot = $sites[$url];

$kirby = new Kirby([
  'roots' => [
    'index'     => __DIR__,
    'base'      => $base = dirname(__DIR__),
    'site'      => $base . '/site',
    'content'   => $domainRoot . '/content',
    'media'     => $domainRoot . '/media'
  ]
]);

echo $kirby->render();

The front works good but when I navigate to local.domain_1/panel I get a blank page. If I inspect that blank page I can see that all the assets (css and js) are missing. So I tried to copy the root/domain_1/media folder to root/public/media and it all works. So it looks like the media root from the index.php doesn’t point to the right place. But the content folder works fine, so what am I missing?

1 Like

I think the media folder must be publicly accessible, which it isn’t if it is above the public root folder.

Well that makes sense of course. I will rethink my folder structure and test that.

I still have trouble with the media folder.
I have now change the folder structure to be like:

root
 |-- kirby
 |
 |-- public
 |    |-- assets
 |    |
 |    |-- media
 |    |    |-- domain_1
 |    |    |-- domain_2
 |    |
 |    |-- index.php
 |
 |-- site
 |-- storage
 |    |-- accounts
 |    |
 |    |-- domain_1
 |    |    |-- cache
 |    |    |-- content
 |    |    |-- sessions
 |    |
 |    |-- domain_2

And then in the public/index.php

<?php
include dirname(__DIR__) . '/kirby/bootstrap.php';

$sites = [
  'local.domain_1' => 'domain_1',
  'local.domain_2' => 'domain_2
];

$url  = Url::host();
$baseRoot = dirname(__DIR__);
$storageRoot = dirname(__DIR__) . '/storage';
$domainRoot = dirname(__DIR__) . '/storage/' . $sites[$url];
$mediaRoot = __DIR__ . '/media/' . $sites[$url];

$kirby = new Kirby([
  'roots' => [
    'index'     => __DIR__,
    'site'      => $baseRoot . '/site',
    'accounts'  => $storageRoot . '/accounts',
    'cache'     => $domainRoot . '/cache',
    'sessions'  => $domainRoot . '/sessions',
    'content'   => $domainRoot . '/content',
    'media'     => $mediaRoot
  ]
]);

echo $kirby->render();

I left the accounts and media folders empty to force a new panel install. Still getting a blank panel page. I can see that the Panel installer have created the necessary panel and plugins folder inside the public/media/domain_1. If I copy them one level up to the public/media folder it works. Is it not possible to have my own sub folders for each domain inside the media folder?

Probably not, because the media route is hardcoded, also see this thread: Routing to /media content instead of /media folder structure

Ok, so it might be a bug… Thank you for your answers.

This one is fixed now with the Kirby 3.1.3 version. Everything is working great now. Thanks for all the help.