admin管理员组文章数量:1026989
I have written a simple plugin to send some security http headers. I've tested it on various wordpress installations but on a wordpress multisite network it seems that the headers are not sended. The plugin is active for the entire network and in the .htaccess
file there is no instruction to set the headers. Is there any error with my code?
<?php
if(! defined('WPINC') ){
die;
}
class WP_Security_Headers{
public function init(){
add_action('send_headers', array($this, 'set_http_headers'));
}
private function set_http_headers(){
header("Strict-Transport-Security: max-age=31536000; includeSubDomains");
header("Set-Cookie: HttpOnly;Secure");
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' ; img-src 'self' data:; style-src 'self' 'unsafe-inline' ; font-src 'self' data:; object-src 'none'; frame-src ; ");
header("X-Frame-Options: SAMEORIGIN");
header("X-Xss-Protection: 1; mode=block");
header("X-Content-Type-Options: nosniff");
header("Referrer-Policy: strict-origin");
header("X-Pingback: ");
header("X-Powered-By: ");
}
}
$wp_s = new WP_Security_Headers;
$wp_s->init();
?>
I have written a simple plugin to send some security http headers. I've tested it on various wordpress installations but on a wordpress multisite network it seems that the headers are not sended. The plugin is active for the entire network and in the .htaccess
file there is no instruction to set the headers. Is there any error with my code?
<?php
if(! defined('WPINC') ){
die;
}
class WP_Security_Headers{
public function init(){
add_action('send_headers', array($this, 'set_http_headers'));
}
private function set_http_headers(){
header("Strict-Transport-Security: max-age=31536000; includeSubDomains");
header("Set-Cookie: HttpOnly;Secure");
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' ; img-src 'self' data:; style-src 'self' 'unsafe-inline' ; font-src 'self' data:; object-src 'none'; frame-src ; ");
header("X-Frame-Options: SAMEORIGIN");
header("X-Xss-Protection: 1; mode=block");
header("X-Content-Type-Options: nosniff");
header("Referrer-Policy: strict-origin");
header("X-Pingback: ");
header("X-Powered-By: ");
}
}
$wp_s = new WP_Security_Headers;
$wp_s->init();
?>
本文标签: pluginssendheaders don39t work on wordpress multisite
版权声明:本文标题:plugins - send_headers don't work on wordpress multisite 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745654962a2161542.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论