如何在Windows中添加Apache2(XAMPP)运行时参数

时间:2016-10-05 09:23:42

标签: apache xampp apache2

我正在尝试在Windows下为xampp设置开发变量,以便执行此操作:

<IfDefine !development>
  AuthType Basic
  AuthName "Say the secret word"
  AuthUserFile /var/www/hostname/.htpasswd
  Require valid-user
</IfDefine>
在Linux上

你可以这样做

export APACHE_ARGUMENTS=-Ddevelopment

如何在Windows上执行此操作?我试过了

set APACHE_ARGUMENTS=-Ddevelopment

但它没有用。

有什么想法吗?

编辑:尝试将启动参数添加到apache服务配置,但也没有帮助。

1 个答案:

答案 0 :(得分:1)

这可能是Apache .htaccess - applying basic authentication conditionally based on environment or hostname

的副本

我通过使用'Allow from ....'指令解决了这个问题。

这样我可以根据IP地址进行覆盖启用

以下是 .htaccess 文件的内容

Order deny,allow
Deny from all
AuthType Basic
AuthName "Secure Area"
AuthUserFile "/path/to/file/.htpasswd"
Require valid-user
Allow from 127.0.0.1
Satisfy Any