This section shows you, how the extension exactly works, why the development was necessary and how to setup step by step.
Why this extension?
The behaviour so far:
If a FILE (eg. my_new_index.htm) was not found, the user got by default the browsers errorpage displayed. If a Typo3-Page was not found, the behaviour was (in my opinion) strange: A (to me) random page was displayed (if a page was displayed). If the pased id wasn´t a number the page inside the page-tree one level above the current page was called.
It also didn't work to assign to a domainrecord a specific error-page, only an errorpage for ALL domains.
Now the behaviour is quite straight forward: If a page or file was not found the extension looks for an errorpage that is assigned to the current domain and displays it. If no errorpage was found, then you get a clear message. The extension also automaticly sends an email to the administrator that the current URL was not found including the referer (if available).
How does it exactly work?
When a page or a file was not found, the (overwritten) function pageNotFoundHandler () in class.tslib_fe.php extracts the domain of the current URL and searches for a corresponding domain with an errorpage in the table sys_domain.If it was found a redirect to the new URL is done.Therefore you have to assign of course in the page-administration an errorpage to a domainrecord, a feature that offers you this extension.
Remark on File-not-found: A directive in the .htaccess redirects to a new page in the root of your website which is similar to the index.php in the root. It then simply calls again the function pageNotFoundHandler () in class.tslib_fe.php.
Setup
Although you have to adjust some parts manually with modifying some files it should not make any trouble at all.
After installing the extension you find in the extension's folder another folder called “files”.
This folder contains the files 404page_not_found.php and example.htaccess.
First of all copy the file 404page_not_found.php into the root of your domain (same directory that contains the files clear.gif, index.php and showpic.php).
Then open the file example.htaccess in a texteditor AND the file .htacess that you find again in the root of your website (see above). If there is no file called .htacess then create a empty text-file in the root and rename it to .htacess !
Into the .htaccess in the root paste the following lines out of example.htaccess or from here at the very end of the file:
ErrorDocument 404 /path_to_your_typo_root/404page_not_found.phpErrorDocument 500 /path_to_your_typo_root/404page_not_found.php
Just make sure that the path is set correctly!
Now go to the install-tool of typo3 in your administration, look for the flag [warning_email_addr] and insert here an emailaddress where a message shall be send if a page was not found.
Nearly done!
You just have to open each domainrecord and assign an URL with or without http:// in the field “Redirect to an URL if a page...”. That's it!
One remark: It doesn't matter in which format the URL of the domainrecord is.If the requested URL http://www.mydomain.com wasn´t found, then the extension will find as domainrecord http://www.mydomain.com as well as www.mydomain.com, as well as http://mydomain.com as well as mydomain.com.