Bug #16167
closedpageNotFound_handling returns 301 instead of 404 as status code
0%
Description
Problem: if $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] is set to
absolute or relative URL, than
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] is ignored
and client is redirected to error page using code 302. This is
especially bad for search engines like Google because (1) they may not
remove such pages from their index (2) sitemaps do not work properly.
Solution: use t3lib_div::getURL() to fetch error page internally and
pass it to client with correct header. getURL() is extended to accept
custom HTTP headers that we need to send to 404 page (referrer and user
agent).
Patch was discussed in the "core" list and Martin Kutschker voted for it. So only one "+1" is missing. Patch is attached.
(issue imported from #M3532)
Files
Updated by Helmut Hummel over 18 years ago
Since 404_v2.txt did not work for me and I found 404_v3a.txt (as well done by Dmitry Dulepov) on the team-core Mailinglist, which works perfectly, I post this Patch here for convenience.
Updated by Helmut Hummel over 18 years ago
Since 404_v3c.txt did not work, I found, that the function file_get_contents is called wrong! Please check this because it is in SVN (both typo3_4_0 and trunk) the wrong way. This ist how it works for me (diff from trunk):
Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php (revision 1615)
+++ t3lib/class.t3lib_div.php (working copy)@ -2372,7 +2372,7
@
);
if (function_exists('file_get_contents')) {
- $content = @file_get_contents($url, $ctx);
+ $content = @file_get_contents($url);
}
elseif (false !== ($fd = @fopen($url, 'rb', false, $ctx))) {
$content = '';
Updated by Helmut Hummel over 18 years ago
Patch above is nonsens but:
404_final.txt is checked in in SVN and is working. I think this one can be closed.