Skip to content

Commit

Permalink
Fix webSiteRootURL if Apache Alias directive is used
Browse files Browse the repository at this point in the history
When Apache Alias directive is used to map AVideo installation on
a given URL prefix, webSiteRootURL should be derived from the
CONTEXT_PREFIX environment variable

Superseeds merge request WWBN#9883
  • Loading branch information
manu0401 committed Feb 15, 2025
1 parent 311753f commit 3a69457
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions install/checkConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@
\$global['disableTimeFix'] = 0;
\$global['logfile'] = '{$_POST['systemRootPath']}videos/avideo.log';
if(!empty(\$_SERVER['SERVER_NAME']) && \$_SERVER['SERVER_NAME']!=='localhost' && !filter_var(\$_SERVER['SERVER_NAME'], FILTER_VALIDATE_IP)) {
// get the subdirectory, if exists
\$file = str_replace(\"\\\\\", \"/\", __FILE__);
\$subDir = str_replace(array(\$_SERVER[\"DOCUMENT_ROOT\"], 'videos/configuration.php'), array('',''), \$file);
// get the subdirectory, through CONTEXT_PREFIX if Apache Alias
// directive is used, or from DOCUMENT_ROOT otherwise
if (!empty(\$_SERVER['CONTEXT_PREFIX'])) {
\$subDir = \$_SERVER['CONTEXT_PREFIX'];
} else {
\$file = str_replace(\"\\\\\", \"/\", __FILE__);
\$subDir = str_replace(array(\$_SERVER[\"DOCUMENT_ROOT\"], 'videos/configuration.php'), array('',''), \$file);
}
\$global['webSiteRootURL'] = \"http\".(!empty(\$_SERVER['HTTPS'])?\"s\":\"\").\"://\".\$_SERVER['SERVER_NAME'].\$subDir;
}else{
\$global['webSiteRootURL'] = '{$_POST['webSiteRootURL']}';
Expand Down Expand Up @@ -234,4 +239,4 @@
$obj->success = true;
echo json_encode($obj);

error_log("Installation: ".__LINE__);
error_log("Installation: ".__LINE__);

0 comments on commit 3a69457

Please sign in to comment.