Subdomains to specific content folders

Hello again, I have a question.
I installed one Kirby, purchased one domain, and connected the website.
There are three menus on the website. Now, the client requests to add three subdomains so that each of the three menus can access the subdomains.
I even applied for a sub-domain, but I can’t access it. What should I do? I need help…!

Main domain: dy.co.kr
Sub domatin: power.dy.co.kr / auto.dy.co.kr / innovate.dy.co.kr

FTP





index.php

<?php

require __DIR__ . '/kirby/bootstrap.php';

$sites = [
  'dy.co.kr' => 'dy',
  'power.dy.co.kr' => 'power',
  'auto.dy.co.kr' => 'auto',
  'innovate.dy.co.kr' => 'innovate',
];

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

How did you configure the subdomains? Do they all point to the www folder on the server?

It’s a very silly question, but… Where can I configure the subdomain? Is there a way to point to the www folder of the server? Now, I copied and placed the original website folder in all directories (connected to subdomains).

If the domain part of the hosting package, then you would configure the subdomains in the control panel of the hosting service.

If, however, the domain was bought from a domain registrar other than the hosting service, you would configure it there.

The whole purpose of the settings in index.php is to direct the different domains/subdomains which all point to the same address, to the right folders.

‘auto’, ‘power’, and ‘innovate’ are directory names, and ‘auto.dy.co.kr’, ‘power.dy.co.kr’, and ‘innovate.dy.co.kr’ are the addresses I applied for as subdomains. I applied for all three from a domain company that purchased ‘dy.co.kr’.

Could you let us know what the column headings say in your table? Not familiar with Korean language…

I’m sorry!

Keep in mind what I wrote above: All domains have to be be directed to the main index.php file in the www directory, not to the individual subfolders.

This is the explanation of the domain company.
Each directory is created when subdomains are added. So three subdomains have three different directories.

Sub-domain management.

  • When you create a subdomain, a directory to connect the subdomain to the bottom of the www folder in your account will be created, and you can upload files such as index to that directory.
  • The file name of the start page of the site using the subdomain should be index.

That’s how it usually works if you have independent websites in each of those folders. But in the case of a Kirby multisite, it won’t work and all domains have to point to the main index.php in www.

Or you have to use four independent Kirby websites, where each site has its own index.php and kirby folder and all the rest.

This domain company makes sure to create each directory when creating subdomains. Subdomain cannot be created on www. So, is the only way to install ‘kirby’ as much as the number of subdomains? Did I understand your explanation correctly?

Yes, if you cannot configure those subdomains, then you need a separate installation in each folder.

What you could do, however, if possible on the server, is move the kirby folder into the www folder and symlink it: A variant to using Kirby for multiple sites | Kirby CMS

I have one more question. I’m sorry.
As in the example below, I hoped that the address of some menus on the website would be “menu.dy.co.kr,” which looks like an individual website, not the way of “dy.co.kr/menu’.”
The management page should be able to be managed in one way.
This is why I applied for subdomain.
However, my domain company said “subdomain = each directory”…
so I have to install Kirby three more times.
Is there any other way?

main website
dy.co.kr/kr
dy.co.kr/en

main website > menu 'power’
dy.co.kr/kr/dy-power > power.dy.co.kr
dy.co.kr/en/dy-power > power.dy.co.kr/en

main website > menu 'auto’
dy.co.kr/kr/dy-auto > auto.dy.co.kr
dy.co.kr/en/dy-auto > auto.dy.co.kr/en

main website > menu 'innovate’
dy.co.kr/kr/dy-innovate > innovate.dy.co.kr
dy.co.kr/en/dy-innovate > innovate.dy.co.kr/en

I’m not sure I really understand your setup. Do these different websites really have their own /content, /site and /assets folders? Or have you duplicated everything into the power etc. subfolders?

It’s really weird that the hosting service enforces a structure on you, never seen anything like this.

1 Like

I think the problem is that you combine 2 possible methods of implementing a multisite setup which should not be combined:

Method 1: Installing Kirby as multisite like it is demonstrated in this cookbook recipe. You did this as far as I can tell from your screenshots showing the folder structure and the content of your index.php.

Method 2: Configuring subdomains with your hosting provider which points to different subfolders of your hosting space. You did this as well.

These methods are mutual exclusive. In order for method 1 to work properly it is important that all of your intended domain names point to the same server in DNS setup and to the same virtual host/webroot. Then the adopted index.php in this webroot folder will take care of dispatching to the correct content, assets etc. folders for the resp. subdomain but all of them are served by the same kirby program folder, i.e. by the same application.

In order for method 2 to work properly, you need to set up as many applications in every subfolder, because your hosting provider dispatch requests for a given subdomain into that folder, hence there must be a complete Kirby installation (without any modification in index.php) in this folder - which you do not currently have.

The best solution in my point of view is to delete the subdomain settings at your hosting provider (assuming this will not delete the resp. folders) and it should work with the folder structure and the index.php you posted on top.

Having said that, it is still not very clear to me what you are trying to achieve. Both methods above will lead to 4 websites with independent content, the only difference is that in method 1 the kirby program folder is shared between these installations.

1 Like

@Adspectus @texnixe
thank you so much for your help.
After discussion, I decided to separate the four websites into four separate hosting and separate domains. I don’t use subdomains… Of course, if you do this, the four websites cannot be managed as one administrator page, but I think it will be okay…!