Php 如何修复上的XSS保护https://example.com/wp-includes/css/
我在谷歌上搜索了一下,找到了关于XSS保护和防止内容类型嗅探的解决方案 我已经在.htaccess文件中应用了以下代码。我仍然面临着错误Php 如何修复上的XSS保护https://example.com/wp-includes/css/,php,wordpress,Php,Wordpress,我在谷歌上搜索了一下,找到了关于XSS保护和防止内容类型嗅探的解决方案 我已经在.htaccess文件中应用了以下代码。我仍然面临着错误 <IfModule mod_headers.c> Header set X-XSS-Protection: "1; mode=block" Header set X-Content-Type-Options nosniff Header always set Strict-Transport-Security "max-ag
<IfModule mod_headers.c>
Header set X-XSS-Protection: "1; mode=block"
Header set X-Content-Type-Options nosniff
Header always set Strict-Transport-Security "max-age=16070400"
</IfModule>
标题集X-XSS-Protection:“1;模式=块”
标题集X-Content-Type-Options nosniff
标头始终设置严格的传输安全性“最大年龄=16070400”
如何解决此问题
将其放入
functions.php
文件:
add_action('send_headers', function(){
// Enforce the use of HTTPS
header("Strict-Transport-Security: max-age=31536000; includeSubDomains");
// Prevent Clickjacking
header("X-Frame-Options: SAMEORIGIN");
// Prevent XSS Attack
header("Content-Security-Policy: default-src 'self';"); // FF 23+ Chrome 25+ Safari 7+ Opera 19+
header("X-Content-Security-Policy: default-src 'self';"); // IE 10+
// Block Access If XSS Attack Is Suspected
header("X-XSS-Protection: 1; mode=block");
// Prevent MIME-Type Sniffing
header("X-Content-Type-Options: nosniff");
// Referrer Policy
header("Referrer-Policy: no-referrer-when-downgrade");
}, 1);
你可以按原样使用它,也可以去掉你不需要的东西
来源:试试这个: