Using .htaccess, I am catching unfound pages and sending them to 404.php My site used to be ASP.net and is now php. Most of the links are corrected in .htaccess for .aspx pages to .php, but I have some coming in which are case insensitive. For example MyPAGE.aspx need to be MyPage.php.
My 404 page is showing, and in it I can adjust the uri as appropriate and display the link. But it will not redirect by itself.
My code in the 404 file is as such.
<?php
$uri = $_SERVER["REQUEST_URI"];
echo "<p>" . $uri . "</p>";
$pos = stripos($uri, "mypage.php");
if ($pos)
{
$uri = str_ireplace ("mypage.php", "MyPage.php", $uri);
header('Location: ' . $uri);
echo sprintf("<p>Please try : <a href='%s'>%s</a></p>",$uri,$uri);
}
?>
Instead of redirecting, it is showing the link - which works.