Menu

News

Monday 20. of November 2006 Speed up PHP5 and Mysql on osx

Friday 01. of September 2006 New version of phpadsnew

Wednesday 26. of July 2006 Me and my macBook

Saturday 03. of June 2006 Advanced pop-up and acronym manager

Site Sponsors

Advertise using Text-Link-Ads

CMS Solutions

System CMS

 

Foro Apple

Foro Apple

 

Cocktails

Cocktails of the World

of the world!

Want to advertise here?

Single page or site-wide advertisements. Gain your PR with back-links from a high ranked site.

Click here to request more information

Letting TYPO3 sending a appropriate 404 is a often asked question on Opens external link in new windowtypo3-english .

Background:

When people manage there website, and in this case deleting page then we need to make sure that all search engines also need to know that a page doesn't exist anylonger.

By default (correct me if I am wrong) TYPO3 3.8.x will find the nearest page but will not send out a appropriate 404 header

Shown using live HTTP headers.
=>  GET /productos-planos/dgdfg.html HTTP/1.1
<=  HTTP/1.x 200 OK

Good news for RCx testers and users for the upcomming 4.0 release, In TYPO3 version 4.0 this particular problem is solved.

Shown using live HTTP headers.
=> GET /nopage.html HTTP/1.1
<= HTTP/1.x 404 Not Found

 The solution:

The solution for TYPO3 users on version 3.8.1

I found it that for some reason it is really not possible to make TYPO3 version 3.8.x send a appropriate header. TYPO3 does provide 'some' answers but looking at the code it simply doesn't send a real header("HTTP/1.0 404 Not Found"); Am I wrong here????

My solutions consist of two steps, first we need to create under typo3conf/localconf.php the following entry:

 
$TYPO3_CONF_VARS["FE"]["pageNotFound_handling"] = 'USER_FUNCTION:fileadmin/scripts/pagenotfound.php:user_pagenotfound->pagenotfound';      

By doing this we tell TYPO3 that we have our own code for 404 handling.
Under fileadmin/scripts/ we create the following file pagenotfound.php.

<?php

define('REDIRECTPAGE', '/404.html');

class user_pagenotfound {

    function pagenotfound($param, $conf) {
        $server_name = $_SERVER['SERVER_NAME'];
        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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Page not Found!</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function doRedirect() {
    window.location="http://'.$server_name.REDIRECTPAGE.'";
}

doRedirect();
// -->
</script>

</head>
<body style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;text-align:center;";>
<div style="font-size:20px;text-align:center">The page you have requested cannot be found</div>
<div>If you are not automaticly redirected in 3 seconds please click here: <br />
<br /><a href='.$server_name.'>'.$server_name.'</a></div>
</body>
</html>';
exit;
}
}

?>

How does it work:

When TYPO3 can't find a page it will call the function pagenotfound in the class user_pagenotfound. Then my PHP code will send a appropriate header and shows a message. Using java I set a timeout and after 1000 ms java fires and calls doRedirect.
When java was not available then a user can always click the provided link.

Note: I have tried to do a header Location: But this was not processed by my browsers correctly, also some proxy servers seem to choke on it

Now to tell you the truth, I copied this from a other site I have been working on and I don't use it on my domain. On the other site I use ltg_googlesearch in combination with realUrl to automaticly send a GET var with the name of the page that couldn't be found. But I am sure you can modify the php to your own needs.


If you have any questions,
let me know
Opens window for sending emailries(at)remove-this.vantwisk.nl