我试图在所有情况下使用Apache的mod_headers设置标头,除了特定路径。我尝试了以下三种变体中的每一种,但它们似乎都无法正常工作以排除路径。在所有情况下,我都会获得所有请求的标头,包括那些与示例路径匹配的请求,例如:http://example.com/charts/24_hour_commodity/450/300
<VirtualHost *:8200>
...
SetEnvIfNoCase Request_URI "^/charts/.*" frameallow
Header set X-Frame-Options SAMEORIGIN env=!frameallow
...
</VirtualHost>
或:
<VirtualHost *:8200>
...
Header always set X-Frame-Options SAMEORIGIN
<LocationMatch "^/charts">
Header always unset X-Frame-Options
</LocationMatch>
...
</VirtualHost>
或
<VirtualHost *:8200>
...
Header always set X-Frame-Options SAMEORIGIN
<Directory "/full/path/to/charts">
Header always unset X-Frame-Options
</Directory>
...
</VirtualHost>
#tried both with and without the 'always' in all configs
有人可以帮我弄清楚为什么在第一个示例中设置了标头,还是在接下来的两个示例中未设置标头?任何一种可行的解决方案就足够了...
更新:在了解了Apache站点上的处理顺序后,我尝试使用条件块代替。这些都不起作用:
<If "%{REQUEST_URI} =~ m#^/charts#">
Header unset X-Frame-Options
</If>
或
SetEnvIfNoCase Request_URI "^/charts" frameallow
<If "reqenv('frameallow') == 1">
Header unset X-Frame-Options
</If>
所以,还是坏了。必须是关于Header语句在处理的特定时间点之后未触发的某些信息。或是他有条件地以某种方式在主要对手之前开火并被覆盖。但是,找不到找到将其调试到根本原因的方法。
标题总是设置Access-Control-Allow-Origin *“ expr =%{REQUEST_URI} =〜m#^ / specialPath $#”
这可能会添加标题wen expr = true
http://httpd.apache.org/docs/current/mod/mod_headers.html
在“标题指令”部分的底部