Include security headers in the .htaccess

API Interface
Contents

    Include security headers in the .htaccess


    To add HTTP response headers in WordPress, you just need to add the following lines to your .htaccess file.

    First, log in to your WordPress hosting account and go to the root folder of your WordPress site from there. Then search for the .htaccess file and edit it.

    As this is a (.) file, it may be hidden. If you cannot find the .htaccess file in the root folder, go to the settings and click on “Show hidden files”.

    Now insert the following line at the end:

    Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
    
    Header set X-XSS-Protection "1; mode=block"
    
    Header set X-Content-Type-Options nosniff
    
    Header always append X-Frame-Options SAMEORIGIN
    
    Header referrer policy: no-referrer-when-downgrade

    After adding, save the file and your security headers are integrated.

    Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

    Updated on 29. March 2024
    Was this article helpful?

    Leave a Reply

    Your email address will not be published. Required fields are marked *