Bug #16988
closedpageNotFound doesn't perform a real 301-redirect
0%
Description
I configured the pageNotFound-handling, that in case of a 404-error , typo3 should send a "301 Moved Permanently" header an redirect to the root page.
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'http://www.example.org';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.x 301 Moved Permanently';
But it didn't works. The header is sent correctly but there's no real redirect to my root page. Only the content of the root-page is presented under the wrong url.
To make it work , i extended the pageNotFoundHandler in class.tslib_fe.php
Orig :
if (false === $content) {
// Last chance -- redirect
header('Location: '.t3lib_div::locationHeaderUrl($code));
} else {
Changed:
if ( (false === $content) || (strstr($header,'Moved Permanently')) ) {
// Last chance -- redirect
header('Location: '.t3lib_div::locationHeaderUrl($code));
} else {
now, the method checks if "Moved Permanently" is used in the pageNotFound_handling_statheader . If so, it will perform the real redirect.
(issue imported from #M4988)
Files