2
0
forked from Wavyzz/dolibarr

FIX Pb in redirect of a website page in USEDOLIBARRSERVER mode

This commit is contained in:
Laurent Destailleur
2024-02-17 15:10:42 +01:00
parent 2c8ffdc160
commit 00f69f90e6

View File

@@ -544,7 +544,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
unset($tmpwebsitepage);
}
if ($result > 0) {
$currenturi = $_SERVER["REQUEST_URI"];
$currenturi = $_SERVER["REQUEST_URI"]; // Example: /public/website/index.php?website=mywebsite.com&pageref=mywebsite-home&nocache=1708177483
$regtmp = array();
if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) {
if ($regtmp[0] == $containerref) {
@@ -559,13 +559,14 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
}
} else { // When page called from virtual host server
$newurl = '/'.$containerref.'.php';
$newurl = $newurl.(empty($_SERVER["QUERY_STRING"]) ? '' : '?'.$_SERVER["QUERY_STRING"]);
}
if ($newurl) {
if ($permanent) {
header("Status: 301 Moved Permanently", false, 301);
}
header("Location: ".$newurl.(empty($_SERVER["QUERY_STRING"]) ? '' : '?'.$_SERVER["QUERY_STRING"]));
header("Location: ".$newurl);
exit;
} else {
print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")";