aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/http/HttpUtils.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/http/HttpUtils.php')
-rw-r--r--application/http/HttpUtils.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/application/http/HttpUtils.php b/application/http/HttpUtils.php
index 4fc4e3dc..9f414073 100644
--- a/application/http/HttpUtils.php
+++ b/application/http/HttpUtils.php
@@ -369,7 +369,11 @@ function server_url($server)
369 */ 369 */
370function index_url($server) 370function index_url($server)
371{ 371{
372 $scriptname = $server['SCRIPT_NAME'] ?? ''; 372 if (defined('SHAARLI_ROOT_URL') && null !== SHAARLI_ROOT_URL) {
373 return rtrim(SHAARLI_ROOT_URL, '/') . '/';
374 }
375
376 $scriptname = !empty($server['SCRIPT_NAME']) ? $server['SCRIPT_NAME'] : '/';
373 if (endsWith($scriptname, 'index.php')) { 377 if (endsWith($scriptname, 'index.php')) {
374 $scriptname = substr($scriptname, 0, -9); 378 $scriptname = substr($scriptname, 0, -9);
375 } 379 }
@@ -392,7 +396,7 @@ function page_url($server)
392 $scriptname = substr($scriptname, 0, -9); 396 $scriptname = substr($scriptname, 0, -9);
393 } 397 }
394 398
395 $route = ltrim($server['REQUEST_URI'] ?? '', $scriptname); 399 $route = preg_replace('@^' . $scriptname . '@', '', $server['REQUEST_URI'] ?? '');
396 if (! empty($server['QUERY_STRING'])) { 400 if (! empty($server['QUERY_STRING'])) {
397 return index_url($server) . $route . '?' . $server['QUERY_STRING']; 401 return index_url($server) . $route . '?' . $server['QUERY_STRING'];
398 } 402 }