On Sunday 03 October 2004 00:10, David Banning wrote: > I notice on some web sites when you try to load a page that does not > exist, it directs the users browser to another page. How do I set > that up in apache?
If you have PHP installed, you can use the following PHP code: <?php header("Location: http://www.newurl.com"); ?> Of course this has the beauty that you can set up a PHP script as a 404 handler, and if you know the old location of a page, then it is very trivial to automatically re-direct to this new location (since you know the path that was requested). We use something like this on the KDE web site: http://webcvs.kde.org/cgi-bin/cvsweb.cgi/www/media/includes/classes/class_handler404.inc?rev=1.4 e.g. <?php include("handler.inc"); $handler = new Handler404(); $handler->add("/anoncvs.html","http://developer.kde.org/source/anoncvs.html"); $handler->add("/family.html","/family/"); ?> where the 1st parameter to add() is the requested original URL, and the 2nd parameter is the URL to redirect to. -- Cheers, Chris Howells -- [EMAIL PROTECTED], [EMAIL PROTECTED] Web: http://chrishowells.co.uk, PGP ID: 0x33795A2C KDE/Qt/C++/PHP Developer: http://www.kde.org
pgpiRW8odZkkW.pgp
Description: PGP signature