Issue Bug Closed

#16988pageNotFound doesn't perform a real 301-redirect

Dirk Diebel 02/14/07, 13:55 updated 11/06/10, 00:10

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)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.