根据运行Web应用程序的服务器,使用不同的.htaccess文件?

I have a test-server and a production-server. I need different .htaccess files for test and production. On test I want the PHP 'display errors' to be on, but I don't want that on production of course.

I know I can set 'display errors' in PHP too, but then I have to do that in each script that I run. Doing it with :

php_flag display_errors On

in .htaccess in the root folder is much easier.

So my question is, how can I make 2 different .htaccess files and depending on the server automatically use the right one?

Apache is using a configuration directive to find these files:

AccessFileName .htaccess

So if you change your development server with

AccessFileName .htaccessdev

in /etc/apache2.conf , then you can handle 2 versions of settings, one for production in .htaccess and one for development in .htaccessdev. Security filters are usually fine and defined this way:

<Files ~ "^\.ht">
  Order allow,deny
  Deny from all
</Files>

which covers both names.