diff --git a/README.md b/README.md index 26a4006..2237e8c 100755 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ - `Models/` : modèles MVC backend (ancien `models/`) - `Thirds/` : dépendances tierces backend (ancien `third/`) -Note: configure the web server at the repository root; requests to `/` are routed to `public/` via `.htaccess`. +Note: configure the web server at the repository root; requests to `/` are routed to `public/` via `.htaccess`, and URLs are generated from the app root. diff --git a/public/views/d.blog.list.rss b/public/views/d.blog.list.rss index 0bd66a3..05c3bbb 100755 --- a/public/views/d.blog.list.rss +++ b/public/views/d.blog.list.rss @@ -19,7 +19,7 @@ echo (''); ?> L'actualité du blog officiel de Kabano : Plateforme collaborative de recensement de cabanes et refuges. fr - public/views/img/header_rss.svg + views/img/header_rss.svg Kabano 44 diff --git a/src/Core/config.example.php b/src/Core/config.example.php index b6daf77..5cdaa0c 100755 --- a/src/Core/config.example.php +++ b/src/Core/config.example.php @@ -28,8 +28,20 @@ $abs_root = rtrim(realpath($config['abs_root_folder']), DIRECTORY_SEPARATOR); $config['rel_root_folder'] = ""; if ($document_root && $abs_root && $document_root === $abs_root) { $config['rel_root_folder'] = "/"; +} elseif ($document_root && $abs_root && strpos($abs_root, $document_root) === 0) { + // Prefer app root when the document root points above the repository. + $config['rel_root_folder'] = substr($abs_root, strlen($document_root)); +} elseif ($document_root && $public_root && $document_root === $public_root) { + $config['rel_root_folder'] = "/"; } elseif ($document_root && $public_root && strpos($public_root, $document_root) === 0) { + // Fallback when the public folder sits under the document root. $config['rel_root_folder'] = substr($public_root, strlen($document_root)); + $public_suffix = "/".trim(basename(rtrim($config['public_folder'], "/")), "/"); + $public_suffix_length = strlen($public_suffix); + if (strlen($config['rel_root_folder']) >= $public_suffix_length + && substr($config['rel_root_folder'], -$public_suffix_length) === $public_suffix) { + $config['rel_root_folder'] = substr($config['rel_root_folder'], 0, -$public_suffix_length); + } } $config['web_root_folder']="https://kabano.test/"; if($config['rel_root_folder']=="" || $config['rel_root_folder']=="/") {