Posted by Veikko Mδkinen on 06/02/05 17:48
Peter Van Hove wrote:
> 1.
> Static yes. Understood. Changing everything is not an option right now
> because I need the same page-names and extensions for
> link-from-outside-purposes.
> If I change them to php all the links to these pages will be lost.
>
How about still changing them and handling 404 error with php?
Here is the trick for Apache:
#file /home/user/public_html/.htaccess
ErrorDocument 404 /404.php
#file /home/user/public_html/404.php
<?
$www = $_SERVER['DOCUMENT_ROOT'];
$path = dirname($_SERVER['REQUEST_URI']);
$file = basename($_SERVER['REQUEST_URI'], '.html');
if (file_exists($www.$path.$file.'html'))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://{$_SERVER['HTTP_HOST']}{$path}{$file}.php");
}
else
header("HTTP/1.0 404 Not Found");
?>
Didn't test it, but you'll get the idea anyway :)
-veikko
--
veikko
mail@ .com
makinen
[Back to original message]
|