When looking at my web log I found a lot of 404 errors and was wondering why, until I received an email from a user complaining about capital letters in my directory structure. For example this webpage is http://panmental.de/public/programming_projects/ciURLs/ and users might easily get the capital "URL" wrong. However with this costum error script page you can as well type (or click) http://panmental.de/public/programming_PROJECTS/ciurls/ and will still arrive here! Now also corrects typos or swapped letters like here: http://panmental.de/public/programming_porjects/ciurls/.
Instead of directly displaying a "not found" error message the script tries to find a case mismatch; if it finds an alternative page the user will be sent there.
Using this script on your server requires two simple steps:
1) Download the php script file to your PC and then upload it to the base directory of your webserver.
2) To make your web server use that file for error messages you have to add the following to the .htaccess file (resp. create a file named .htaccess with that content if non-existent) in the base directory of your webserver:ErrorDocument 404 /error.phpThat's it!
When you open the downloaded script with a text editor you will find the following options in the first lines:$email="email@example.com"; //email of web page owner (yours) $name="John Smith"; //name of web page owner (yours) $delay="1"; //delay until forwarding in seconds $dist_limit="2"; //how different are URLs allowed to be considered a typo $error_page=""; //your own html error page, e.g. "error.html" or leave "" for defaultChange these to appropriate values if you like. For
$dist_limitsee the Levenshtein description at the PHP site; it measures the difference of strings by calculating the minimal number of characters you have to replace, insert or delete to transform ont string into the other. The default value 2 allows for omitting two characters or one swap in the URL.
This is http://ciURLs.panmental.de
I do not guarantee the correctness/adequateness of the script or the information given on this side and thus deny any responsibility for your use of it.
Johannes Knabe (firstname.lastname@example.org)
v0.2 Hatfield, UK, 02.11.2007 (2007/Nov/02) - Now also corrects typos or swapped letters in the URL
v0.1 Hatfield, UK, 01.11.2007 (2007/Nov/01)
My Homepage is http://panmental.de