28 Jan 2010
8

How to turn off PHP errors, notices and warnings within .htaccess

Last month we released a post called How to disable notice and warning in PHP.ini file which show you how to turn off PHP errors, notices and warnings within php.ini file. Today we want to show you another solutions to turn off PHP errors, notices and warnings within .htaccess file

PHP errors, notices, and warnings may be turned off by adding the following code within a website’s .htaccess file:

php_flag display_errors off

Besides potentially interfering with a website’s visual appearance, it is generally not a good idea to display errors, notices, and warnings within a production environment for security reasons, since the error messages may provide useful information on a server / website’s configuration, and thus how to circumvent its security measures.

Rate this post:
(6 votes)

8 comments

  • Comment Link Lonnie Lazar Saturday, 18 December 2010 23:06 posted by Lonnie Lazar

    Using .htaccess with this line of code returns a 500 Internal Error on my site.

    Anyone else with a similar issue? Any resolution?

  • Comment Link Otabek Tuesday, 07 December 2010 13:14 posted by Otabek

    You may use php error_reporting() function without .htacces conf. Please see http://php.net/manual/en/function.error-reporting.php

  • Comment Link Eoin Tuesday, 01 June 2010 17:53 posted by Eoin

    how can I test if it's worked? I had errors, I removed the issue altogether, now I'd like to test if it's working without having to reinstall the errors! Previously it did not work, but I don't know why.

  • Comment Link kev Tuesday, 04 May 2010 15:56 posted by kev

    gives my site a 505 error

  • Comment Link PHPNEWB Tuesday, 04 May 2010 14:05 posted by PHPNEWB

    Thanks - I needed this - couldn't get the notices to turn off, tried everything.

  • Comment Link Eugen Radulov Thursday, 04 March 2010 12:53 posted by Eugen Radulov

    thanks for sharing the code line, no more PHP errors

  • Comment Link Tim Monday, 15 February 2010 09:14 posted by Tim

    Thanks, i was looking for this.

  • Comment Link Mark Jones Friday, 12 February 2010 10:55 posted by Mark Jones

    Thanks for posting this, it really helped!

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Search
Top of Page