Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何像这样添加到.htaccess条件?_Php_.htaccess_Header_Mod Headers - Fatal编程技术网

Php 如何像这样添加到.htaccess条件?

Php 如何像这样添加到.htaccess条件?,php,.htaccess,header,mod-headers,Php,.htaccess,Header,Mod Headers,需要添加到.htaccess条件,如下所示: if (page == '/admin') { Header add Test "test" } 这不起作用: <IfModule mod_headers.c> <If "%{REQUEST_URI} == '/'"> Header add Test "test" </If> </IfModule> 标题添加测试“测试” 但这在所有页面上都起作用(逻辑上)

需要添加到.htaccess条件,如下所示:

if (page == '/admin') {
    Header add Test "test"
}
这不起作用:

<IfModule mod_headers.c>
    <If "%{REQUEST_URI} == '/'">
        Header add Test "test"
    </If>
</IfModule>

标题添加测试“测试”
但这在所有页面上都起作用(逻辑上):


标题添加测试“测试”
我知道env=[!]varname,但不知道如何在我的情况下使用

我很高兴能得到任何帮助

指令

<IfModule mod_headers.c>
    <If "%{REQUEST_URI} == '/admin'">
        Header add Test test
    </If>
</IfModule>
现在,请求
/admin
将被重写为
/index.php
,而
请求的URI
将被处理为“/index.php”,并在响应发送到客户端之前设置头,请参阅

正常模式是延迟模式,即在运行content generator和响应头之前立即设置请求头,而响应是通过线路发送的。在操作服务器中始终使用延迟模式



因此,根据在您的环境中处理和修改请求的方式,您还必须将条件
修改为适合您的环境的任何条件。

我想更改特殊页面上的标题
<IfModule mod_headers.c>
    <If "%{REQUEST_URI} == '/admin'">
        Header add Test test
    </If>
</IfModule>
<IfModule mod_headers.c>
    <If "%{REQUEST_URI} == '/admin'">
        Header add Test test
    </If>
</IfModule>

RewriteEngine on
RewriteRule ^admin$ /index.php [L]
<IfModule mod_headers.c>
    <If "%{REQUEST_URI} == '/index.php'">
        Header add Test test
    </If>
</IfModule>

RewriteEngine on
RewriteRule ^admin$ /index.php [L]