Date: Sun, 3 Oct 2004 13:09:48 +0100 From: Chris Howells <howells@kde.org> To: freebsd-questions@freebsd.org Cc: David Banning <david+dated+1097190608.0a8a39@skytracker.ca> Subject: Re: apache - how to redirect page not found Message-ID: <200410031309.52491.howells@kde.org> In-Reply-To: <20041002231007.GA80368@skytrackercanada.com> References: <20041002231007.GA80368@skytrackercanada.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart3406812.K86LBuWXrz Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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=20 handler, and if you know the old location of a page, then it is very trivia= l=20 to automatically re-direct to this new location (since you know the path th= at=20 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_h= andler404.inc?rev=3D1.4 e.g. <?php include("handler.inc"); $handler =3D 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= =20 parameter is the URL to redirect to. =2D-=20 Cheers, Chris Howells -- chris@chrishowells.co.uk, howells@kde.org Web: http://chrishowells.co.uk, PGP ID: 0x33795A2C KDE/Qt/C++/PHP Developer: http://www.kde.org --nextPart3406812.K86LBuWXrz Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBBX+wQF8Iu1zN5WiwRAr7DAKCPXqAMhfFlG9bMtPbH0bbg2ZdFdgCeJuBY +AuAa0INShkxn0RdI7jSuSM= =DsPZ -----END PGP SIGNATURE----- --nextPart3406812.K86LBuWXrz--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410031309.52491.howells>