Hi everyone,
I recently changed my Kirby project to a public folder setup for increased security and to resolve some issues I was having running my project on my server. Unfortunately, it’s still not running on my server, and I keep getting a 500 server error. I’m hosting the website on Netcup and deploying with Git to my master branch. The document root is pointed to the public folder.
Here’s what I did:
- Created a “public” folder in my root directory.
- Moved index.php, media folder, and robots.txt into the public folder.
- Modified index.php like so:
<?php
require __DIR__ . '/../kirby/bootstrap.php';
$base = dirname(__DIR__);
$storage = $base . '/storage';
$kirby = new Kirby([
'roots' => [
'index' => __DIR__,
'site' => $base . '/site',
'content' => $base . '/content',
'accounts' => $storage . '/accounts',
'cache' => $storage . '/cache',
'sessions' => $storage . '/sessions',
'logs' => $storage . '/logs',
]
]);
echo $kirby->render();
- Modified kirby/router.php like so:
<?php
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// Emulate Apache's `mod_rewrite` functionality
if ($uri !== '/' && file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $uri)) {
return false;
}
$_SERVER['SCRIPT_NAME'] = '/public/index.php'; // this
require $_SERVER['DOCUMENT_ROOT'] . '/' . $_SERVER['SCRIPT_NAME'];
My questions are:
- I use PostCSS, should my node_modules folder be inside the public folder? The package.json is in my project root.
- I’m confused about the .htaccess file. Should it be inside the public folder on the server?
- Did I catch all necessary changes? I know there is a guideline in the docs but it was not detailed enough for me to understand.
I have two local branches: main
and public-folder-setup
. The main
branch doesn’t render my templates (no HTML, no CSS), and I can only access the panel after switching to my old-setup branch. Otherwise, I just get a white screen when trying to access the panel. Here the .htaccess is inside the public folder.
The public-folder-setup
branch has the .htaccess in the root directory and it renders all HTML and CSS.
When running my page locally, the panel login points to http://localhost:8000/public/panel/login, while my start page is simply http://localhost:8000/.
I suspect I’ve messed up some important routing.
My goal for now is to understand these problems and get my project running locally. I want to switch from the internally available Kirby server to MAMP to better emulate the server configurations of the Netcup server. My next step would be to push these changes to Netcup and do further troubleshooting if needed.
Any hints would be greatly appreciated.