Subdomains from kirby folders

Hello again,

I have a question re: setting up subdomains for different kirby folders (single installation)
The website I’m working on, is not managed by kirby. However, we are using a single installation to make and

The file structure looks like this: => /content/1-one => /content/2-two

I tried doing it in the multi-page setup along this template

$kirby   = kirby();
$domain  = server::get('server_name');
$domains = array('', '');

but it didn’t work even with the server name provided (i tried without it too of course)
The server is Apache 2.4 if that info is any relevant to the problem.

Using different pages of the same content directory is not recommended, because then the two sites will share the same site.txt and the templates and blueprints.

If you really want to do it this way (for example to maintain both sites from the same Panel account), you could create a plugin in the site/plugins directory that redirects either to kirby()->urls()->index() . '/one' or '/two' by checking the server name. Keep in mind that the URI will contain /one//two in this case.

The recommended way is to use a multi-site setup as described in the docs. You posted a snippet of this code, but maybe you didn’t understand correctly how it works: You would have two completely separate content and site directories, and their names would be the domains, not 1-one and 2-two. You would also have two different instances of the Panel with different users.

1 Like

I guess I didn’t (still not very good at php)
I would like to do it the recommended way, but having a pair of content, site and panel directories pretty much means a second installation (?) Please correct me if I’m wrong

What do you mean by “second installation”? Your two sites would still share the same kirby and panel directories, but everything else would be specific to the domain.

I always thought is was possible to share the site folder with templates etc. as well, but maybe I’m mistaken :pensive:

Yes, you are right. That would require changing the example code in the documentation, but it should be possible. Keep in mind that the Panel still won’t give access to both sites at the same time, you will have to login to each one individually (but with the same account in this case).

Hey, thank you for your replies by far. I’m trying to do it the way you recommended, and just wanted to double check if the file structure is right.



If you use the example site.php code from the docs, it should be the following structure:


Great, thank you so much!

MAMP is giving me error 500 now though, is there a way of testing the setup locally?

Error 500 means that there’s probably something wrong with PHP/the Kirby installation. Could you please take a look at the logs in the /Applications/MAMP/logs/ directory, especially at the error_log?

I’m getting
PHP Fatal error: Call to a member function isErrorPage() on boolean in /Users/username/cms/kirby/kirby.php on line 359

which is:

 // react on errors for invalid URLs
    if($page->isErrorPage() and $page->uri() != $path) {

The reason for this is most likely that there is no error page in your content directory of the site you are currently accessing.

I didn’t have it to begin with
After changing the server_name in site.php and moving it to a test server I’m getting something different:

[16-Nov-2015 16:35:05 Europe/Berlin] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Users/username/cms/index.php:2) in /Users/username/cms/kirby/toolkit/lib/s.php on line 131

Surprisingly, now I can access the panel for the page I’m at, though the page is still blank

Edit: actually everything besides the home page for each subdomain is working. How odd?

This error means that something has already been output before Kirby could load. Are you sure there’s no output whatsoever?

It’s finally right now, the last obstacle was really trivial: in my previous setup, the home page was better off in the content directory, instead of it’s own ‘home’ folder.
The multi-site setup definitely requires it though.
Well that was silly of me

Thank you for you patience @lukasbestle!!