Project

General

Profile

Actions

Bug #16988

closed

pageNotFound doesn't perform a real 301-redirect

Added by Dirk Diebel almost 18 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Communication
Target version:
-
Start date:
2007-02-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

class.tslib_fe.php.diff (2.54 KB) class.tslib_fe.php.diff Administrator Admin, 2007-02-14 13:55
bug_4988.diff (525 Bytes) bug_4988.diff Administrator Admin, 2007-02-22 08:06
Actions #1

Updated by Helmut Hummel about 17 years ago

If you want to send a redirect, if a page is not found, aou can simply use
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'REDIRECT:http://www.example.org'; (302 Header is sent)

Or you can use USER_FUNCTION:/file.php:class->function() in order to do what you want...

Actions #2

Updated by Dirk Diebel about 17 years ago

i think this is obsolete.

in version 4.1.2 i fixed , the problem this way:

$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = ' REDIRECT: http://www.example.org';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.x 301 Moved Permanently';

Actions #3

Updated by Chris topher about 14 years ago

Resolved, fixed.

In current versions (I just tested this again with 4.5.0alpha3, but this also works with older versions) you can also get a 301 Redirect with these settings:
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = '/404.html'; // A page inside TYPO3
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.1 404 Not Found';

Actions

Also available in: Atom PDF