【问题标题】:htaccess turn on php flags if certain IP address如果某个 IP 地址,htaccess 打开 php 标志
【发布时间】:2015-09-05 23:50:46
【问题描述】:

在我的 .htaccess 文件中,我需要打开以下内容:

php_flag display_errors On
php_value error_reporting 2147483647

但是,如果我的 IP 正在访问该站点,我只想这样做。

有什么想法吗?

类似...

if (ip == "x.x.x.x") {
  php_flag display_errors On
  php_value error_reporting 2147483647
}

需要在 .htaccess 中而不是在 PHP 中执行此操作,谢谢!

【问题讨论】:

    标签: php apache .htaccess


    【解决方案1】:

    您实际上可以在 Apache 2.4 中使用 If 指令执行此操作。我不确定所有 php_flag 命令都以这种方式工作,但有些可以。

    例如,

    <If "%{REMOTE_ADDR} = 'XXX.XXX.XXX.XXX'">
        php_flag xdebug.remote_autostart On
        php_flag xdebug.remote_enable On
    </If>
    

    【讨论】:

      【解决方案2】:

      在 httpd 配置中没有简单的方法可以做到这一点。考虑改用auto_prepend_file 中的脚本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-09-25
        • 2014-07-10
        • 2013-09-01
        • 1970-01-01
        • 2011-06-01
        • 1970-01-01
        • 2014-02-05
        • 1970-01-01
        相关资源
        最近更新 更多