【问题标题】:How to allow external sources in an iframe with a local .htaccess file?如何在具有本地 .htaccess 文件的 iframe 中允许外部源?
【发布时间】:2020-02-25 08:19:30
【问题描述】:

我的.htaccess 文件在目录中:

Header always set Content-Security-Policy "frame-src 'self' https://xxxx.de; frame-ancestors 'self' https://xxxx.de"

我的 iframe:

<iframe style="border: 0; position:fixed; top:0; left:0; right:0; bottom:0; width:100%; height:100%;" src="https://xxxx.de/test.html"></iframe>

但浏览器显示“内容安全策略”阻止网站加载外部内容。我该如何解决这个问题?

【问题讨论】:

    标签: html apache .htaccess


    【解决方案1】:

    有两种使用内容安全策略的方法:

    1.设置确切的域路径。

    2.设置匹配域模式。

    例如1:

    Header always set Content-Security-Policy "frame-src 'self' 
    https://xxxx.de/test.html; frame-ancestors 'self' https://xxxx.de/test.html"
    

    例如2:

    Header always set Content-Security-Policy "frame-src 'self' 
    https://xxxx.de/*; frame-ancestors 'self' https://xxxx.de/*"
    

    【讨论】:

      猜你喜欢
      • 2015-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      • 2010-11-19
      • 2018-10-14
      • 2021-09-01
      相关资源
      最近更新 更多