Htaccess setup subfolder

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.