Disipal Network  
Go Back   Disipal Network > Tutorials > PHP


Reply
 
LinkBack Thread Tools Display Modes
Old 05-27-2009, 11:58 AM   #1 (permalink)
Administrator
 
Disipal's Avatar
 
Join Date: Mar 2009
Location: Athens (Greece)
Posts: 220
Send a message via MSN to Disipal Send a message via Skype™ to Disipal
Default Advanced PHP Error Handling via htaccess

Prevent public display of PHP errors via htaccess
Code:
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
Preserve (log) your site’s PHP errors via htaccess
Code:
# enable PHP error logging
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
Protect your site’s PHP error log via htaccess
Code:
# prevent access to PHP error log
<Files PHP_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
Controlling the level of PHP error reporting
Using htaccess, it is possible to set the level of error reporting to suit your particular needs. The general format for controlling the level of PHP errors is as follows:
Code:
# general directive for setting php error level
php_value error_reporting integer
Setting the maximum file size for your error strings
Using htaccess, you may specify a maximum size for your PHP errors. This controls the size of each logged error, not the overall file size. Here is the general syntax:
Code:
# general directive for setting max error size
log_errors_max_len integer
Disable logging of repeated errors
If you remember the last time you examined a healthy (or sick, depending on your point of view) PHP error log, you may recall countless entries of nearly identical errors, where the only difference for each line is the timestamp of the event. If you would like to disable this redundancy, throw down the following code in the htaccess file of your project root:
Code:
# disable repeated error logging
php_flag ignore_repeated_errors on
php_flag ignore_repeated_source on
Putting it all together — Production Environment
Having discussed a few of the useful ways to customize our PHP error-logging experience, let’s wrap it all up with a solid, htaccess-based error-handling strategy for generalized production environments. Here is the code for your target htaccess file:
Code:
# PHP error handling for production servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting 999999999
log_errors_max_len 0
 <Files /home/path/public_html/domain/PHP_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
Disipal is offline   Reply With Quote
Old 03-11-2010, 10:21 AM   #2 (permalink)
Junior Member
 
Join Date: Mar 2010
Posts: 1
Default Re: Advanced PHP Error Handling via htaccess

It was really a good experience to read out from here
__________________
ccna security and windows 7 certification and more about a+ certification
CARVER is offline   Reply With Quote
Reply

Bookmarks

Tags
advanced, error, handling, htaccess, php


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT. The time now is 12:35 PM.

Powered by vBulletin® Version 3.8.4. Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Skin designed by Disipal