Hide PHP errors using htaccess

By default, the PHP display_errors setting is set on. You can read more about display_errors at PHP: Error Handling and Logging Functions. There are few important things that you should know about the error messages that is sent to the browser by display_errors.

Usually these error messages contains sensitive information about the web application environment that you are running and could lead to unwanted security threat. It is even stated in the manual that it is not recommended to enable this feature on a production site.

To disable or switch it off (assuming that you’re on a shared hosting which have limited super power), simply add php_flag display_errors off in your .htaccess file.

4 Comments

vm

cool. simple good if don’t have access to php.ini file.

Jc

This is also useful to turn errors on while editing php files on a shared web server (no access to php.ini).

Ambareesh Shrivastav

Cool tip. I had read about turning PHP errors off at a lot of places but no body had bothered to mention the complete code ie php_flag….
Thanks

Zork Nemesis

i dont know how to thank u man … i needed that urgently … u r a real geniuos

Leave a Comment

(required)
(will not be published) (required)