How to set up multisite on localhost?


I try to set up a local multisite, but it’s not working. Maybe someone can help me?

My folder looks like this:

Bildschirmfoto 2021-06-15 um 11.26.03

My index.php (in folder “multisitetest”) like this:

require 'kirby/bootstrap.php';

$sites = [
  'site-one' => 'site-one',
  'site-two' => 'site-two',

$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();

Trying to open localhost/multisitetest/ results in “… currently offline due to an unexpected error.” I also don’t know where to enable debug mode.The debug mode in the site/configs of the subpages is already enabled.

I am glad for help :slight_smile:

I would try adding a config with turned on debug mode directly in site/config/config.php so if there is something not working with the folder-setup this config will do its work and show the debug log.

$host = Url::host();

This will return the host and won’t work with subfolders. What is your local development environment? If you are for example using MAMP Pro, you can set up hosts that point to the same folder.

Thanks for your answer. I’ve added a site/config and this is the result:

Thanks for your help.

I’m using MAMP Pro, but I’m afraid I don’t know 100% what I need to do now to get it running. :blush:

You can create local hosts, e.g. site-one.test, site-two.test etc., see MAMP PRO (macOS) Documentation > Create a new host

These two hosts would then both point to the multisitetest folder.

You would then also have to change the $sites array to use the full hosts names site-one.test, like in the example in the docs.

1 Like

Cool, it’s working!

  1. I’ve added the two Hosts via MAMP Pro

  2. My multisitetest folder needed a htaccess with RewriteBase /

  3. The $sites part in my index.php looks like this:

$sites = [
  'site-one.test' => 'site-one',
  'site-two.test' => 'site-two',

Thank you so much!

@pixelijn startet using MAMP PRO today, so it’s probably a noob thing, but while trying to set the same document root for two hosts i get this warning:

Any idea what i am doing wrong?

@teichsta That’s what I found as well with the current version of MAMP Pro. It was possible in the past, but not anymore. Don’t know why they’ve done this, really annoying.

thanks for reply … i was about to invest in a PRO license what i am going to (at least) defer a bit now. Any idea which tooling could help with the (local) multisite setup now?

Laravel Valet would be an alternative: Laravel Valet - Laravel - The PHP Framework For Web Artisans

Other alternatives: Docker setup or local Apache setup.

Don’t know how other tools like Xampp handle hosts