If the different sites do not need to access each others content, I think, that it would be the best solution to keep the websites completely separated. So each website has it’s own Kirby installation.
But I don’t know what your specific use case is.
But in this case you would only have to change the RewriteBase line in the .htaccess file from RewriteBase / to RewriteBase /site1name.
I’m using this for developing my websites on localhost.
Otherwise you must create a custom site.php file in your Kirby installation folder as mentioned in the Custom folder setup.
But instead of switching folders my domains, you should be able to get the requested URI by server::get('REQUEST_URI'), trim this string to the first / by using string manipulation and use this as switch for the different sites.
It should be possible, but I have not tested this.
You could also simply use one instalation have first set of folders site1name, site2name, site3name and if you need restrict administration use the new https://getkirby.com/docs/panel/permissions for users
It’s actually a client request - a client who is my guinea pig for a first kirby project, so a good one to start with ha!
They have separate internal departments, all individually branded but sharing a domain name, so I thought it would be good to have one point of control. I’ll try the above and see how I get one.