Htaccess setup subfolder

I’m having a problem with a kirby website on a hosting.

The folder structure configured by this webhosting provider is as follows:

I apologise that its only in czech language but this is a really popular provider in czech republic so i think it might be helpful if this gets solved also for other people having the same problem in the future.

Basically if I login to FTP I need to upload all the files into a folder www/domains/ and it shows up at publicly. This is where i put all the kirby files.

The website shows at but all the links point to

For example $site->homepage()->url() points to
Panel can be found at
Content page at
and so on.

The website is not broken and everything works as it should, just all the links are ugly.

I tried to change the rewrite base in kirby’s .htacess file to / or /domains/ but without any success.

The only thing that worked was setting c::set('url', '');
It fixed all the links but now the panel is not reachable, both or say Invalid panel URL.

Thank you for any advice

Have you tried to set the rewrite base to / while setting the URL like you did.

My assumption is that the .htaccess on the root is causing this problem.

I also think their the root htaccess is going to be the cause :frowning:
I did like you said but this still outputs the Invalid Panel URL message, although the Gui is already like panel’s.

Hm, isn’t there any other way to assign Domains to subfolders than through the .htaccess? Are you using multiple domains on that hosting?

Does that error appear before or after logging in?

Im not using multiple domains right now but i cant guarantuee it will not be the case in the future. Also im not a big expert in .htaccess syntax so i dont know if it can be assigned somehow differently. The actual file used by the hosting is attached in the link in the first post.

And the error page appears before logging in. Even if i add manually /login to the url the error is still there.

@lukasbestle Is this kind of setup supported at all?

The setup is quite similar to the one of the German hosting provider Uberspace, where Kirby works just fine.

What you could try is the following:

  1. In the /www/.htaccess file, delete the [DPI] flags after the first two RewriteRules.
  2. In the /www/domains/ file, set RewriteBase /.

Maybe that works. :slight_smile:

@lukasbestle Ah, I didn’t know they have a similar setup. Thanks for your answer.

Oh, sounds promising! I’ll try this as soon as i get back to work computer and tell you if it worked.
Thank you both so far.

Sorry for taking so long to reply. I set it up as you suggested and it unfortunately still doesn’t work :frowning: Everything behaves the same way as before.

Could maybe this be of any help?

It says that the php applications should retrieve current urls using _SERVER["REQUEST_URI"] instead of _SERVER[“PHP_SELF”] or $_SERVER[“SCRIPT_NAME”].

Might this be the case of kirby?

In case anyone finds themselves in the same situation. I browsed the source code of kirby and realized $_SERVER[“SCRIPT_NAME”] is actually used in many places and I wasn’t able to identify where exactly to change it. So in the end I changed it to not include the domains folder path before even launching Kirby and it seems like it fixed my issue without breaking anything (panel and urls work the way you expect)!

All you need to do is add this line

$_SERVER['SCRIPT_NAME'] = preg_replace('/\/domains\/' . $_SERVER['HTTP_HOST'] . '/', '', $_SERVER['SCRIPT_NAME']);

to the top of index.php file at the root of your kirby project - BEFORE calling echo (new Kirby)->render(); (or echo $kirby->launch(); back in Kirby 2). Hope this helps.