1
0

2 Коммитууд 27901139ee ... 5171cde7ae

Эзэн SHA1 Мессеж Огноо
  Medowar 5171cde7ae final small fixes 1 сар өмнө
  Medowar b886368f79 fixing routing bug 1 сар өмнө

+ 2 - 2
.htaccess

@@ -2,7 +2,7 @@
 Options -Indexes
 
 # Make HTMLy handle any 404 errors.
-ErrorDocument 404 /index.php
+ErrorDocument 404 /blog/index.php
 
 # Set the default handler.
 DirectoryIndex index.php
@@ -90,7 +90,7 @@ DirectoryIndex index.php
 
 # Pass all requests not referring directly to files in the filesystem to index.php.
   RewriteCond %{REQUEST_FILENAME} !-f
-  RewriteCond %{REQUEST_FILENAME} !-d 
+  RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^ index.php [L]
 
 </IfModule>

+ 1 - 1
content/medowar/author.md

@@ -1,5 +1,5 @@
 <!--t Medowar t-->
 <!--d Just another HTMLy user d-->
-<!--image http://localhost/blog/content/images/20260809233200-Medowar-logo.png image-->
+<!--image /blog/content/images/20260809233200-Medowar-logo.png image-->
 
 Sysadmin

+ 11 - 7
system/includes/dispatch.php

@@ -24,7 +24,13 @@ function site_url()
 
 function generateSiteUrl()
 {
-    $dir = trim(dirname(substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"]))), '/');
+    // Collapse repeated slashes and strip by prefix, not by string length: some
+    // hosts hand PHP a SCRIPT_FILENAME whose leading slash is doubled, which
+    // makes a length-based substr() slice one character into the real path.
+    $root = rtrim(preg_replace('#/+#', '/', $_SERVER["DOCUMENT_ROOT"]), '/');
+    $script = preg_replace('#/+#', '/', $_SERVER["SCRIPT_FILENAME"]);
+    $relative = strpos($script, $root . '/') === 0 ? substr($script, strlen($root)) : $script;
+    $dir = trim(dirname($relative), '/');
     if ($dir == '.' || $dir == '..') {
         $dir = '';
     }
@@ -41,12 +47,10 @@ function generateSiteUrl()
 
 function site_path()
 {
-    static $_path;
-
-    if (!$_path)
-        $_path = rtrim(parse_url(site_url(), PHP_URL_PATH), '/');
-
-    return $_path;
+    // Not cached in a static: session.php calls this during autoload, before
+    // config/config.ini is loaded, which would pin the auto-detected path and
+    // make [site.url] ineffective for routing.
+    return rtrim(parse_url(site_url(), PHP_URL_PATH), '/');
 }
 
 function theme_path()