In article <20080218164649.606 DeleteThis @usenet.piggo.com>,
Troy Piggins <usenet-0802 DeleteThis @piggo.com> wrote:
> At present my apache2 server gives a 404 message if someone tries
> to access a non-existent page or file.
>
> On some forums I have posted some links to photos in the past.
> If I want to restructure my server so that those links are no
> longer correct, is there a way in apache to attempt to redirect
> them to the correct page? Or perhaps if someone clicks an old
> link with a certain path in it, they can get a special 404
> message? What do you recommend?
it depends on your restructuration.
If you have moved /your/page.html to /your/old/page.html it's quite easy
to setup a .htaccess file (or <Directory ...> in httpd.conf) so that
error document will be a specially crafted php file that can create a
redirect proposal for the user.
(I don't think an automatic redirect triggered by an error is a good
thing).
I'm using this kind of trick on my server. After moving a bunch of
directories from /some-directory/ to /some-directory/my-new-dir/, I've
created a 404 error page in php, looking like this:
.../..
<body>
<p>Hello,<br />
The page you're looking for has probably moved</p>
<p>You can try to reach it at this address: <?php echo '<a
href="'.dirname($_SERVER[REQUEST_URI]).'/my-new-dir/'.ba
sename($_SERVER[REQUEST_URI]).'">'.dirname($_SERVER[REQUEST_URI]).'/my-ne
w-dir/'.basename($_SERVER[REQUEST_URI]).'</a>'
; ?></p>
</body>
.../..
and my virtualhost config contains:
<Directory /usr/local/www/host/some-directory>
ErrorDocument 404 /some-directory/404.php
../..
</Directory>
hope this helps,
patpro
--
A vendre !
http://www.patpro.net/blog/index.php/2008/01/12/133