How do I control PHP error display from htaccess?

software development


Here is a snippet in my htaccess. I know the htaccess file is getting touched because I’ve got some AuthType action in it and that’s working properly.

php_flag display_errors off
php_flag display_startup_errors off 

I’m trying to make sure that files in my wordpress distribution don’t display errors when people are ‘hunting’ for some clues to my directory layout.

This doesn’t work because I do a phpinfo() on a file that I’m testing and I see that the display_errors aren’t off.


you can make a custom php.ini file

i think there’s also a bit of code you can write within your application to intercept all errors… a big try{}catch{}? not sure of the specifics though as it’s built into my framework by a php guru


By custom php.ini, do you mean follow the directions here? The reason why putting into my application won’t work because I’m trying to secure wordpress; that is, I don’t want to edit any of the core files from the deployment. I’ll look into creating a custom php.ini file.


I was trying to do what you are trying to do. I found this

post by sXi (Grizzled Veteran).
I followed his directions and added the line
display_errors = 0
into the phprc file. Now php errors are logged and not shown to users.