Merge pull request #13 from LeOSW42/copilot/update-root-url-access

Serve Kabano from site root instead of /public
This commit is contained in:
2026-01-24 17:45:06 +01:00
committed by GitHub
4 changed files with 16 additions and 2 deletions

6
.htaccess Normal file
View File

@@ -0,0 +1,6 @@
RewriteEngine On
RewriteRule ^public(/.*)?$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/$1 [L]

View File

@@ -8,3 +8,5 @@
- `Controllers/` : contrôleurs MVC backend (ancien `controllers/`) - `Controllers/` : contrôleurs MVC backend (ancien `controllers/`)
- `Models/` : modèles MVC backend (ancien `models/`) - `Models/` : modèles MVC backend (ancien `models/`)
- `Thirds/` : dépendances tierces backend (ancien `third/`) - `Thirds/` : dépendances tierces backend (ancien `third/`)
Note: configure the web server at the repository root; requests to `/` are routed to `public/` via `.htaccess`.

3
index.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
require __DIR__ . '/public/index.php';

View File

@@ -24,12 +24,15 @@ $config['public_folder'] = $config['abs_root_folder']."public/";
// This is the relative folder to the root of the website from the DocumentRoot (can also be called subfolder) // This is the relative folder to the root of the website from the DocumentRoot (can also be called subfolder)
$document_root = rtrim(realpath($_SERVER['DOCUMENT_ROOT']), DIRECTORY_SEPARATOR); $document_root = rtrim(realpath($_SERVER['DOCUMENT_ROOT']), DIRECTORY_SEPARATOR);
$public_root = rtrim(realpath($config['public_folder']), DIRECTORY_SEPARATOR); $public_root = rtrim(realpath($config['public_folder']), DIRECTORY_SEPARATOR);
$abs_root = rtrim(realpath($config['abs_root_folder']), DIRECTORY_SEPARATOR);
$config['rel_root_folder'] = ""; $config['rel_root_folder'] = "";
if ($document_root && $public_root && strpos($public_root, $document_root) === 0) { if ($document_root && $abs_root && $document_root === $abs_root) {
$config['rel_root_folder'] = "/";
} elseif ($document_root && $public_root && strpos($public_root, $document_root) === 0) {
$config['rel_root_folder'] = substr($public_root, strlen($document_root)); $config['rel_root_folder'] = substr($public_root, strlen($document_root));
} }
$config['web_root_folder']="https://kabano.test/"; $config['web_root_folder']="https://kabano.test/";
if($config['rel_root_folder']=="") { if($config['rel_root_folder']=="" || $config['rel_root_folder']=="/") {
$config['rel_root_folder']="/"; $config['rel_root_folder']="/";
} else { } else {
$config['rel_root_folder'] = "/".trim($config['rel_root_folder'],"/")."/"; $config['rel_root_folder'] = "/".trim($config['rel_root_folder'],"/")."/";