簡體   English   中英

Apache mod_headers 無法取消設置路徑上的標頭

[英]Apache mod_headers cannot unset header on a path

我試圖在所有情況下在 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 語句在處理中的某個點后不會觸發。 或者有條件的那些在主要的之前以某種方式觸發並被覆蓋。 但是,找不到將其調試到根本原因的方法。

帶有表達式的響應頭

Header always set Access-Control-Allow-Origin * "expr=%{REQUEST_URI} =~ m#^/specialPath$#"

這可能會添加標題 wen expr = true

http://httpd.apache.org/docs/current/mod/mod_headers.html

標題指令部分的底部

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM