Letting TYPO3 sending a appropriate 404 is a often asked question on
typo3-english .
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 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.
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
ries(at)vantwisk.nl