Customize 404 "Not found" message by directory

Customize 404 "Not found" message by directory

Post by Chris Lo » Tue, 28 Jan 2003 09:20:00



Hello,

We had to temporarily remove some previously published web pages from
our web server until we get content copyright issues settled. In the
meantime, we're concerned about those users who have bookmarked these
pages and are still trying to access them. Instead of giving them the
standard 404 "Not found" error we would like to display  a special
message informing them of the status of the pages and the interim
measures we are taking. So I would like to know if its possible to
create a unique 404 messages for just those files in this particular
directory of our web tree and also have a other 404 messages for files
in other parts of the tree.

TIA

 
 
 

Customize 404 "Not found" message by directory

Post by D. Stuss » Tue, 28 Jan 2003 19:28:50



>We had to temporarily remove some previously published web pages from
>our web server until we get content copyright issues settled. In the
>meantime, we're concerned about those users who have bookmarked these
>pages and are still trying to access them. Instead of giving them the
>standard 404 "Not found" error we would like to display  a special
>message informing them of the status of the pages and the interim
>measures we are taking. So I would like to know if its possible to
>create a unique 404 messages for just those files in this particular
>directory of our web tree and also have a other 404 messages for files
>in other parts of the tree.

Such is possible in that your 404 page can be a CGI, SSI, PHP, or other server
side interpreted page.

The errordocument directive can be used inside an .htaccess file and inside a
<Directory> construct.  I don't remember offhand if it can be used inside a
<Files> construct, but if it can, and you have a wildcard or a small wildcard
set that describes these files, then it can easily work with a static page.

 
 
 

Customize 404 "Not found" message by directory

Post by Alan J. Flavel » Tue, 28 Jan 2003 22:09:21


On Jan 26, Chris Los inscribed on the eternal scroll:

[..]

Quote:> So I would like to know if its possible to
> create a unique 404 messages for just those files in this particular
> directory of our web tree

Where are you having a problem?  There's so many ways of achieving
this that I'm not clear why you haven't found at least one of them.

To take just one example,  ErrorDocument in .htaccess

http://httpd.apache.org/docs/mod/core.html#errordocument

You might want to consider generating some other error code in your
particular circumstances, rather than the straightforward 404 which
would imply that the page is missing.  Maybe 403 ("it's here but I
shan't let you have it") or 410 ("There was a page here but it's gone
away now").  403 is easy to generate by defining an unsatisfiable
access control condition; if you use a script as your error document
then it's easy to return any code you choose; or you could use
mod_rewrite.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html lists the
precise meaning of the various codes.  I don't see any other values
than 403 or 410 which might be suitable for your situation.