Multi-site on single domain with subfolder urls

Been scouting the docs, cookbook and forum for solutions to setting up a multi-site solution.

Testing with plainkit 3.3.2 with the default .htaccess file.

Works great with examples using a subdomain setup with the index.php below (also on my local valet install) eg.:


However, I’m attempting to point to subfolders instead of the subdomain structure, for the actual project I’m working on, eg.:


index.php in root as follows:

require 'kirby/bootstrap.php';

$sites = [
  'multi.test'    => 'translations/en',
  'multi.test/de' => 'translations/de',

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

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

echo $kirby->render();

Meaning the root domain has english as default, while hitting https://multi.test/de would load the german content in my file structure:

Curious if this is possible?
Still working on my dev skills, ideas would be greatly appreciated :stuck_out_tongue:

Best, Oliver

The problem is that Url::host() will return your domain name, excluding the path. So this can’t possibly work. You could check if the first part of the path is de and then add that to the $host variable.

$host = Url::host();
if (Url::toObject()->path()->first() === 'de') {
    $host = $host . '/de';
$url  = 'https://' . $host;

I guess you have a reason to use the multi-site structure instead of using Kirby’s multi-language feature, i.e. a completely different content structure…