Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Custom error handling in php e.g. 404 not found
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 10th June 00:41
©®
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found



Is it possible to use PHP for generating custom error pages (e.g. 404
not found etc.) instead of .htaccess or other means?
A friend is giving me free webspace so there is no CPanel or any other
kind of assistance that I can make use of.
I tried .htaccess but then for some reason it doesn't show my site.
I saw in a UK magazine (Web Developer) something about this but never
bought the magazine and now can't find what I was looking for at Google.
Any help appreciated.
  Reply With Quote


  sponsored links


2 10th June 01:00
j.o. aho
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found



..htacceess requires

1. Server is running apache
2. usage of .htaccess has been enabled

In .htaccess you can't redefine everything, there are limitations and you can
take a look in the apache manual: http://httpd.apache.org/docs/1.3/howto/htaccess.html


You would need to get every request redirected to one of your pages and that
page would lookup and see if the requested page is there or not, then either
serve the page or generate an error page.

For tuther information you can take a peak at
http://se.php.net/manual/en/function.header.php


//Aho
  Reply With Quote
3 10th June 01:00
zeldorblat
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found


Umm, no. You can tell Apache to use anything as the 404 page (and any
of the other error pages). So, you could have him use 404.php instead
of his default. Make your own 404.php do whatever you like.
  Reply With Quote
4 10th June 01:00
j.o. aho
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found


As it looks like the original poster isn't the webmaster of the server, and
therefore don't have that option to edit the ErrorDo***ent options in the
configuration.


//Aho
  Reply With Quote
5 10th June 01:00
zeldorblat
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found


But he does have access to .htaccess. If Override FileInfo is enabled
for the directory, ErrorDo***ent can be set via .htaccess.
  Reply With Quote
6 10th June 01:01
bill
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found


I would like to know if you can create custom titles and meta based on
the page there error is.


--
Bill

*Kind Regards*
*Bill*
Over 100,000 Posts At The UK Webmaster Forums Today: http://www.ukwebmasterforums.com/
  Reply With Quote
7 10th June 03:56
©®
External User
 
Posts: 1
Default Custom error handling in php e.g. 404 not found


Found the example in the magazine:
---
<?php error_reporting (E_ERROR | E_WARNING | E_NOTICE);
$reportMail = 'you@youremail.com';
$redirectPage = 'http://www.yourdomain.com/error.htm'
function pageError($errno, $errstr, $errfile='?', $errline= '?') {
global $reportMail, $redirectPage;
if (($errno & error_reporting()) == 0)
return;
$err = ' ';
switch($errno) {
case E_ERROR: $err = 'FATAL'; break;
case E_WARNING: $err = 'ERROR'; break;
case E_NOTICE: return;
}
mail($reportMail, "PHP Error: $errfile' $errline",
"$errfile, Line $errline\n$err($errno)\n$errstr");
print '<META HTTP-EQUIV="Refresh" CONTENT="0;url=' .$redirectPage.
'">';
die();
}
set_error_handler('pageError');
?>
---

Then has a further little bit of info:
---
<?php
require('errorphp.php');
print 2/0;
?>
---

Does this example mean I can use my own custom error pages e.g. 404?

As I only had a short time, I didn't get the jist of the whole article
and so am asking for help.
Thanks
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666