Multisite Setup not serving media

Hey,
I’m trying to setup a multi site Kirby instance. I’ve followed the cookbook but it’s not quite working yet.
I’ve taken an existing kirby site and the plainkit and put them in two folders, and on both pages the same errors appear.

The pages are displayed but nothing from the media directories is served. This seems to be related to the uuids, since the uuids kirby is trying to call do not exist - the files are stored with other uuids.
But even with matching uuids it does not work. I can’t open the panel because none of the content in
pageA/media/panel/4c7…/ is being served, the network tab simply says “connection refused”. What do I need to change?

I also needed to replace all asset paths like 'assets/css/...' and 'assets/js/... in the css() and js() helpers with <?= $kirby->root('assets')?> . ‘/css/…’, not sure if this is intended?

Thanks for any help. I’m happy to provide more info to debug this.

Do you mean this recipe: Using Kirby for multiple sites | Kirby CMS

Or this one: A variant to using Kirby for multiple sites | Kirby CMS

The first one! Would you recommend the second?

It shouldn’t matter. What I don’t understand is what UUIDs have to do with it.

You definitely shouldn’t have to adapt the asset paths. Have you followed the recipe by the T, i.e. also set the urls

 'urls' => [
    'media'  => $url . '/' . $root . '/media',
    'assets' => $url . '/' . $root . '/assets',
  ],

?

This is my index.php, basically copied completely from the recipe besides the domains / folders:

<?php
require 'kirby/bootstrap.php';

$sites = [
    'domainA.de' => 'folderA.de',
    'domainB.com' => 'folderB.com',
    'localhost' => 'folderA.de'  # for dev purposes
];

$host = Url::host();
$root = $sites[$host];
$url  = 'http://' . $host;

$kirby = new Kirby([
    'roots' => [
        'index'   => __DIR__,
        'site'    => $root . '/site',
        'content' => $root . '/content',
        'media'   => $root . '/media',
        'assets'  => $root . '/assets'
    ],
    'urls' => [
        'media'  => $url . '/' . $root . '/media',
        'assets' => $url . '/' . $root . '/assets',
    ],
]);

echo $kirby->render();

Regarding the uuids: Here’s a screenshot of the requests loading media when i run page A as a single instance at my directory root:


The file banner-werkstatt.jpg is in the directory b7a...

Now for the multisite setup, I’ve copied everything from my root directory (except the /kirby/ directory) into folderA.de, added the new index.php, and now the request looks like this:

(See next post, I can only add 1 image per post…)

This is the new url / request


note the changed uuid.
(I’ve just noticed that the port is missing from the url, but the same behaviour happens on a real webserver without a port…)

This is not a UUID, but a media hash.

Ah, my bad.
Anyways, I’ve found the problem when I tried again on a webserver: The index.php from the recipe sets the url to http, but something (browser? kirby? I don’t know) tries to enforce https, blocking the media requests. Changing it to https fixed the problem for me.

1 Like