[TYPO3] pageNotFound_handling - 404 error

Ries van Twisk typo3 at rvt.dds.nl
Wed Feb 1 14:46:49 CET 2006


For page not found handeling, in combination with realUrl I wrote my own
function.

By default it works, but I needed to redirect to a search page and that
was when realUrl/typo3 stopped sending my browser 404  messages.

this is what I did:
I added this to my localconf.php
$TYPO3_CONF_VARS["FE"]["pageNotFound_handling"] =
'USER_FUNCTION:fileadmin/scripts/pagenotfound.php:user_pagenotfound->pagenotfound'; 



The pagenotfound.php file looks like this:
<?php

class    user_pagenotfound {
    function pagenotfound($param, $conf) {
    $toReplace = array('_', '-', '/');
    $url = trim(str_replace($toReplace,' ',$param['currentUrl'] ));
    $url = "search/$url/";
    header("HTTP/1.0 404 Not Found");
    print '<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="#internalStyle" type="text/css"?>

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function doRedirect() {
    window.location="http://www.domain.com/'.$url.'";
}

setTimeout("doRedirect()", 1000);
// -->
</script>

</head>
<body style="font-family: Verdana, Geneva, Arial, Helvetica,
sans-serif;text-align:center;";>
<p style="font-size:40px;text-align:center">Page not found!</p>
<p>If you are not automaticly redirected in 3 seconds please click here:
<br />
<br /><a
href="http://www.domain.com/'.$url.'>http://www.domain.com/'.$url.'</a></p>
</body>
</html>';
exit;
}
}

?>

I made the php file tailer made for my site, on the search page I use
realURL that can grab the parameters and does a search directly.
You might want to do something else!!!!!


Try this on my site:
http://www.livetravelguides.com/quito

With live headers enabled, you will see the 404 directly after the get
request then you get redirected to my search page and a search for quito
is performed.
The redirect is done with javascript and not with a Location header,
why??? It simply didn't work adding both headers.
Also this will let you make a nice next + image or anything else you
would like yout users to tell (you already told the spider about the 404)

Let me know if this works for you aswell...

This solution also might work for the guy that has 404 problems with a
multiple domain setup...

Ries



>Hi!
>
>Christine Rochelt wrote:
>  
>
>>Thanks, but no actually I do not use simulateStatic. Any other
>>suggestions?
>>    
>>
>
>Than just use mod_rewrite. I am not a guru in it but there are
>directives to test if file/directory exists or not and redirect
>appropriately. See in example .htaccess, which is supplied with typo3.
>
>Personally I would rather use realurl and old recreate site structure in
>typo3. This will make all old links to the site valid. Also Google will
>be happy, your site will not drop ratings.
>
>Dmitry.
>_______________________________________________
>TYPO3-english mailing list
>TYPO3-english at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>  
>





More information about the TYPO3-english mailing list