My old site was written in plain html, but the new site was built using wordpress. I set it up so that the old page (/page.html) would now be /page/. One thing I didn’t think about was the numerous links into the site using the old .html extension. My solution was to upload all of the old html files up to the new server, but have them redirect to the new pages by taking the current url, stripping .html out of it then redirect to that page. However, I’m not sure what I’m doing. Could anyone tell me what is wrong with this?
<html>
<?php
$a = $_SERVER['REQUEST_URI'];
if (strpos($a,'.html') !== false)
{
$newstring = str_replace(".html", "/", $a);
}
elseif (strpos($a,'.htm') !== false)
{
$newstring = str_replace(".htm", "/", $a);
}
header('Location: ' . $newstring);
exit;
?>
If you have apache running on your machine you could easily redirect all pages that end with “.html” or “.htm”. Just add this into your .htaccess file.