How to fix XSS Protection on https://example.com/wp-includes/css/

Viewed 1018

I googled it and found the solution about XSS Protection and to prevent Content Type sniffing.

I have applied below code in .htaccess file. i am still facing the error.

<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>

How can I fix this issue?

enter image description here

1 Answers

Put this in your functions.php file:

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);

You can use it as it is or you can remove things that u dont need

Source: https://benrabicoff.com/adding-secure-http-response-headers-wordpress/

Related