Bug #20622
closedReverseProxy redirect
0%
Description
t3lib_div::locationHeaderUrl uses t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') or t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR') to get the full url. Is a reverse proxy used, the right variable would be HTTP_X_FORWARDED_HOST. The problem could be minimized, if the host in the url is replaced with the host of baseURL. baseURL is needed in other cases with this configuration to reach the home-page.
the critical line is:
header('Location: '.t3lib_div::locationHeaderUrl($this->redirectUrl));
A simple solution would be:
if(isset ($GLOBALS['TSFE']->baseUrl)){
$url = t3lib_div::locationHeaderUrl($this->redirectUrl);
$purl = parse_url($url);
$pHost = $purl['host'];
$baseurl = parse_url($GLOBALS['TSFE']->baseUrl);
$baseurlHost = $baseurl['host'];
$newUrl = str_replace ($pHost,$baseurlHost,$url);
header('Location: '.$newUrl);
} else {
header('Location: '.t3lib_div::locationHeaderUrl($this->redirectUrl));
}
(issue imported from #M11343)