Multisite with folders

Hi,

I’m trying to create a multisite that shares the same kirby folder.

example.com/site1
example.com/site2
example.com/site3

Not exactly sure how to structure the index.php file :thinking:

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

$sites = [
  'example.com/site1' => 'site1',
  'example.com/site2' => 'site2',
  'example.com/site3' => 'site3',
];

$host = Url::host();
$root = $sites[$host];
$url  = 'https://' . $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();

This will only return example.com but not the subfolder, I think…

Have you already looked at the cookbook recipes Using Kirby for multiple sites and especially A variant to using Kirby for multiple sites?

1 Like

Currently trying the “A variant to using Kirby for multiple sites”, this should work!

Got the symbolic links working but navigating the sites I get the following error:

Warning: require(kirby/bootstrap.php): failed to open stream: No such file or directory in /srv/users/username/apps/example-domain/public/site1/index.php on line 3

Maybe it’s the index.php that doesn’t find kirby/bootstrap.php because kirby is a symbolic link :thinking:

<?php

require 'kirby/bootstrap.php';

echo (new Kirby)->render();

You have to adapt the index.php as well, see the recipe: https://getkirby.com/docs/cookbook/setup/multisite-variant#in-index-php

1 Like

Aaa :man_facepalming: didn’t see the tutorial continued! Working now :muscle: :muscle: thanks!