diff --git a/install.php b/install.php index b3aacfa9..3ec6ea5c 100644 --- a/install.php +++ b/install.php @@ -34,8 +34,9 @@ define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS); define('DOMAIN', $_SERVER['HTTP_HOST']); // HTML PATHs -$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; -$base = dirname($base); +//$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +//$base = dirname($base); +$base = empty($_SERVER['REQUEST_URI']) ? dirname($_SERVER['SCRIPT_NAME']) : dirname($_SERVER['REQUEST_URI']); if($base!=DS) { $base = $base.'/'; diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 030db91f..20684580 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -153,12 +153,23 @@ $Url = new Url(); $Parsedown = new ParsedownExtra(); $Security = new Security(); -// HTML PATHs -$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; -$base = dirname($base); +// HTML PATHS +// The user can define the base URL. +// Left empty if you want to Bludit try to detect the base URL. +$base = ''; + +if( !empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base) ) { + $base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']); + $base = dirname($base); +} +elseif( empty($base) ) { + $base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; + $base = dirname($base); +} if($base!=DS) { - $base = $base.'/'; + $base = trim($base, '/'); + $base = '/'.$base.'/'; } else { // Workaround for Windows Web Servers