Friday, September 28, 2007

Custom php redirect in my 404 document

I have given up on getting to have Wordpress presenting permalinks in a form that would enable my old pebble links to actually hit the same post in Wordpress. This doesn't mean that it will never happen but I will leave it for now.

What I have done is the follwing. I added this to my 000-default in sites-enabled
<Directory /www/htdocs/yoursite>
AllowOverride FileInfo
</Directory>

Since i only know of this problem to exist inside my blog I edited the .htaccess inside the blog directory with the line below
ErrorDocument 404 /error404.php

I then create a file called error404.php in the root of my web server that contains the text below



<?php
//errror404.php
echo "<font size="3"><center><strong>
You have reached a page that has changed, moved or is no longer available.<br>
You will be forward to the front page.<br>
If you came from a search engine please use the search box on the front page to find what you were looking for.<br>
If you came from a bookmark - please update the bookmark appropriately</strong></center></font>";
echo "<meta http-equiv="refresh" content="2;URL=/index.php">";
?>

This way all "old" links will be directed to the frontpage of my blog and not to the regular 404 doc from Apache

No comments: