Merge pull request #18 from LeOSW42/copilot/update-link-access-method

Normalize routing base to drop /public from URLs
This commit is contained in:
2026-01-24 19:23:29 +01:00
committed by GitHub
3 changed files with 14 additions and 2 deletions

View File

@@ -9,4 +9,4 @@
- `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`. 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.

View File

@@ -19,7 +19,7 @@ echo ('<?xml version="1.0" encoding="UTF-8"?>'); ?>
<description>L'actualité du blog officiel de Kabano : Plateforme collaborative de recensement de cabanes et refuges.</description> <description>L'actualité du blog officiel de Kabano : Plateforme collaborative de recensement de cabanes et refuges.</description>
<language>fr</language> <language>fr</language>
<image> <image>
<url><?=$config['web_root_folder']?>public/views/img/header_rss.svg</url> <url><?=$config['web_root_folder']?>views/img/header_rss.svg</url>
<title>Kabano</title> <title>Kabano</title>
<link><?=$config['web_root_folder']?></link> <link><?=$config['web_root_folder']?></link>
<height>44</height> <height>44</height>

View File

@@ -28,8 +28,20 @@ $abs_root = rtrim(realpath($config['abs_root_folder']), DIRECTORY_SEPARATOR);
$config['rel_root_folder'] = ""; $config['rel_root_folder'] = "";
if ($document_root && $abs_root && $document_root === $abs_root) { if ($document_root && $abs_root && $document_root === $abs_root) {
$config['rel_root_folder'] = "/"; $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) { } 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)); $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/"; $config['web_root_folder']="https://kabano.test/";
if($config['rel_root_folder']=="" || $config['rel_root_folder']=="/") { if($config['rel_root_folder']=="" || $config['rel_root_folder']=="/") {