In order to avoid 404 pages showing up for incorrect letter cases, all file names should be lower case and when not matching from an old link an htaccess process to convert uri to lower case.
1 – The .htaccess file
Code (text):
-
RewriteEngine On
-
RewriteBase /
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteRule .* http://www.domain.com/badRequests.php [L]
2 – badRequests.php
PHP:
-
<?php
-
// get the lowercase version of the URI
-
$lower = strtolower($_SERVER[‘REQUEST_URI’]);
-
// If the URI isn’t the same as the lowercase version, redirect to the lowercase version
-
if($_SERVER[‘REQUEST_URI’] !== $lower) {
-
header(‘Location: ‘.$lower);
-
die();
-
}else{
-
//Otherwise give a 404 error
-
header(“HTTP/1.0 404 Not Found”);
-
die();
-
//You could remove the die() line above of course to allow this to execute
-
//This will send the user to the errordocument.php file, where you can show
-
//your custom error document file if you wish
-
header(‘Location: /errorDocument.php’);
-
die();
-
}
3 – an optional errorDocument.php file containing your error message