How to enable display_errors with .htaccess

I have the following environment on one server:

  • dev.domain.com for development
  • test.domain.com for tests
  • www.domain.com is an ongoing production.

For dev-Environment, I would like to see all PHP errors (including parsing errors). Unfortunately, the PHP configuration is pretty strict. It does not allow setting display_errors in a PHP file. Means what

ini_set("display_errors", 1); 

and all its options do not work. The following works fine in a .htassess file:

 php_flag display_errors "1" 

So my idea was to do something like this:

 if(HOST==dev.domain.com) { php_flag display_errors "1" } 

I tried SetEnvIf, RewriteCond, IfDefine and other options. No success.

Is there any way to do this?

+7
source share
2 answers

As I mentioned in my comment, you can set display_errors using ini_set() , but this will not help with parsing errors, as noted in the manual

Can you make changes to the VirtualHost sections for each site? If so, add php_flag there.

If not, why not just create a different .htaccess file for each site?

+1
source

Just ignore the .htaccess file in your version control system and create a separate file for each set of options on each server.

0
source

All Articles