Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache 有条件设置X-Frame-Option_Apache_Ibmhttpserver - Fatal编程技术网

Apache 有条件设置X-Frame-Option

Apache 有条件设置X-Frame-Option,apache,ibmhttpserver,Apache,Ibmhttpserver,我试图使用基于ApacheHTTPServer2.2.32的IBMHTTPServer(IHS)8.5.5.12设置X-Frame-Options 我试过使用setenif,但不知道如何比较httpd.conf文件中的环境变量 我在IHS 9中使用If条件尝试了相同的方法,但不知道如何在IHS 8.5.5.12中实现相同的方法 <IfModule mod_headers.c> <If "%{HTTP:X-Requested-From} == 'mobileapp'"&g

我试图使用基于ApacheHTTPServer2.2.32的IBMHTTPServer(IHS)8.5.5.12设置X-Frame-Options

我试过使用setenif,但不知道如何比较httpd.conf文件中的环境变量

我在IHS 9中使用If条件尝试了相同的方法,但不知道如何在IHS 8.5.5.12中实现相同的方法

<IfModule mod_headers.c>
    <If "%{HTTP:X-Requested-From} == 'mobileapp'">
        Header unset X-Frame-Options
    </If>
    <Else>
        Header set X-Frame-Options SAMEORIGIN
    </Else>
</IfModule>

标题未设置X帧选项
标题集X-Frame-Options SAMEORIGIN
以上代码在IHS9中运行良好,这里有人能帮忙吗

问候

Mohammad Ashfaq

这里的技巧是,
Header
指令在Apache2.2中可以是有条件的,但只能基于环境变量。但是
setenif
首先运行,并且可以基于请求头设置环境变量:

SetEnvIf X-Requested-From mobileapp is_mobile=1
Header set X-Frame-Options SAMEORIGIN
Header unset X-Frame-Options env=is_mobile


$ wget -qS  http://localhost 2>&1 |grep X-F   X-Frame-Options:
SAMEORIGIN 
$ wget -qS  --header="X-Requested-From: mobileapp"
http://localhost 2>&1 |grep X-F 
$