开发者

Use a different .htaccess file depending on the server the web application runs on?

开发者 https://www.devze.com 2023-02-27 03:13 出处:网络
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 cour

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 P开发者_如何学运维HP 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消