通過nginx或php禁止iframe

1、通過nginx,對chrome瀏覽器適用
/etc/nginx/nginx.conf
在http下
添加 add_header Content-Security-Policy "frame-ancestors *.888.com";
或者 add_header Content-Security-Policy "frame-ancestors *.888.com *.999.net";

2、通過php,對ie瀏覽器適用,chrome不支持X-Frame-Option的allow-from
在相關php文件內的<?php下添加
header('X-Frame-Options: allow-from http://player.888.com/');

如果有多個域名可以添加如下
header('X-Frame-Options: allow-from http://player.888.com/');
header('X-Frame-Options: allow-from http://player.999.net/');

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章