DNS aliases & Subdomain for multiple kirby installs

I have set up a static site using Netlify which is going to be my new homepage, accessible using my own domain (mysite.com). This should be fairly simple. However, I’m sometimes using my own server to give clients a preview of their site at mysite.com/clients/kirby-site.

If I understand correctly, aliasing mysite.com to mysite.netlify.com would also break currently working links to mysite.com/clients.
Which could be fine, because my hosting provider has the option to access subdirectories using subdomains out of the box, so clients.mysite.com/kirby-site will work. This however breaks all generated internal links. Is there something I’m doing wrong when creating links in Kirby? Can I programmatically check if the current domain is clients.mysite.com or some-other-site.com and change routes depending on that (which I would prefer not to do)?

Or is there even a way to achieve both via DNS, an alias of mysite.com to myapp.netlify.com while somehow still being able to access mysite.com/subdirectory? (I’m still trying to get the hang of DNS records, but shouldn’t it somehow be possible for mysite.com/* pointing back to my server even if the actual domain is an alias?)

That’s what I would have suggested as well. What do you mean with it breaks internal links? It shouldn’t usually be necessary to set the subfolder in the .htaccess but you could try.

I don’t really know what’s going wrong: clients.mysite.com/kirbysite renders correctly. If I click on any link, it
a) doesn’t load stylesheets for that page. On clients.mysite.com/kirbysite/page-1, a request is being made to https://clients.mysite.com/clients/kirbysite/assets/css/style.css
b) the code inside the template is not being rendered (header and footer snippets work, so there’s only the main nav)
c) any further links on that page are again repeating the surplus /clients/ in the link

i’m kind of suspecting this to be an error of my hosting provider rather than kirby cms…

how exactly would I need set the subfolder? Would I then need to manually change .htaccess depending on the domain it’s hosted on?

So your structure actually has a clients folder and inside that clients folder the kirby projects?

You could try to set the url for each project in the config.

yeah, exactly. There’s actually nothing speaking against just skipping the clients section entirely, maybe I should try that.

Since you can define different config files for a multi-environment-setup: would this work?:

// config.mysite.test.php
return [
  'url' => 'http://mysite.test'
// config.clients.mysite.com.php
return [
  'url' => 'https://clients.mysite.com/kirbysite'

Seems kind of redundant to me, because the setup doesn’t understand the correct host url to begin with…

Edit: tried adding the url explicitly in config. Now, stylesheets are being loaded and links are working, but there’s still no content being rendered from templates. Also $page->isActive() is not working :confused:

Edit 2: tried moving the site out of the clients subfolder to kirbysite.mysite.com, now most of the template content on kirbysite.mysite.com is working except for linked stylesheets and different other assets. Links are generated to kirbysite.mysite.com/kirbysite/*

Edit 3: if I now explicitly set the url in a config.kirby-project.mysite.com.php file like indicated above, everything appears to be working. Except ssl encryption but I guess this might just take a while for them to issue. I’m actually starting to like the shape of the different URLs like this;

kirby-project.test // local dev
kirby-project.mysite.com` // "staging" 
kirby-project.com // production

thank you for your help as always!