SunnyOne
SunnyOne

Reputation: 193

htaccess error reporting

Can anyone tell me how I can create a 500 error to check if my error page, 500.php, is ok? I would like to send e-mail alerts to myself when some types of error occurs, how can I do this?

I read a lot, but didn't find much.

Upvotes: 0

Views: 650

Answers (5)

AllInOne
AllInOne

Reputation: 1450

I think the easiest way to trigger and 500 error would be to load an invalid .htaccess file

So create a new directory somewhere where Apache can see it and in that directory upload a file named .htacesss with the following contents:

Redirect

This is invalid syntax since you aren't giving all the required Redirect parameters and will reliably generate a 500 error in my testing.

Upvotes: 1

Sascha
Sascha

Reputation: 957

If you want to monitor your site, i would suggest to use a service like pingdom (they and many others have free plans). These services also alerts you if the server does not process php any more.

Upvotes: 0

Comatose
Comatose

Reputation: 11

How to send an e-mail with php:

if($stuffExploded==true)
{
    $to      = '[email protected]';
    $subject = 'Oh, By the way...';
    $message = 'Stuff exploded on page 64, line 221. Good going.';

    mail($to, $subject, $message);
}

Upvotes: 0

Steve Robbins
Steve Robbins

Reputation: 13812

You can force it with

header('HTTP/1.1 500 Internal Server Error');

Then on your 500.php page use mail()

Upvotes: 1

Sangar82
Sangar82

Reputation: 5230

For the point 2:

 I would to send e-mail alerts to myself when some types of error occurs what track to follow ?

Use Google Webmasters tool:

http://www.google.com/webmasters/

Webmasters tools can help you to detect all the server errors and helps you to optimize your site, is a great tool.

More info:

http://en.wikipedia.org/wiki/Google_Webmaster_Tools

Upvotes: 1

Related Questions