rklau Posted December 10, 2003 Posted December 10, 2003 Hi - I have a snippet of php code I want to execute in my 404 page. I have created a custom 404 page through cPanel, assigned the filename of 404.php at the bottom, and confirmed that (a) the file is written properly and ( when accessed directly (i.e., www.rklau.com/404.php) it works fine. But when you access a page that doesn't exist, I get this: The requested URL /foo was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I tried manually updating .htaccess with this: ErrorDocument 404 /home/xxxxx/public_html/404.php But that is what seems to generate the error message above. So - how do I direct 404's to 404.php instead of 404.shtml? --Rick Quote
borfast Posted December 10, 2003 Posted December 10, 2003 That's odd... I think it should work. Try using a relative path to the file instead - instead of using ErrorDocument 404 /home/xxxxx/public_html/404.php use just ErrorDocument 404 404.php Quote
rklau Posted December 10, 2003 Author Posted December 10, 2003 Sorry, but that doesn't work either. Now I get this: The requested URL /foo was not found on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. I'm stumped... Quote
rklau Posted December 11, 2003 Author Posted December 11, 2003 Well, fool around enough with something and you can make it work. Turns out the line has to read: ErrorDocument 404 /404.php Go figure. For those who are interested, I implemented this hack in Movable Type: http://www.rklau.com/tins/archives/2003/12...mtrefsearch.php Which lets me capture incoming referral links to help people find what they want on my blog; now the 404 page includes the same code. (I'm going to have to modify the 404 one a bit to include both blogs hosted at my domain, but you get the idea.) Now, when they get referred to a non-existent page from a search engine, the first thing the 404 page does is execute a query against my blogs - if there are posts that contain the search strings used at the search engine, it will present links to those posts before just presenting the visitor with a standard search interface. --Rick Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.