{"id":18932,"date":"2026-10-21T20:17:45","date_gmt":"2026-10-21T17:17:45","guid":{"rendered":"https:\/\/www.hyyat.com\/knowledgebase\/security-headers\/"},"modified":"2026-10-21T20:17:53","modified_gmt":"2026-10-21T17:17:53","password":"","slug":"security-headers","status":"publish","type":"docs","link":"https:\/\/www.hyyat.com\/en\/knowledgebase\/security-headers\/","title":{"rendered":"Security Headers: What They Are and How to Add Them to Your Website"},"content":{"rendered":"<div class=\"hkb\" dir=\"ltr\">\n<div class=\"hkb-tldr\"><b>In short<\/b>Security headers are lines the server sends with every page, asking the browser to behave more safely: always open your site over https, never show your site inside other sites, never guess file types, and only load scripts from approved sources. You add them with a few lines in .htaccess and test them with a free tool.<\/div>\n<figure class=\"hkb-fig\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/10\/hkb-security-headers.webp\" alt=\"Security headers: a browser window with a list of security settings and a large shield\" width=\"1200\" height=\"630\" loading=\"lazy\" \/><\/figure>\n<h2>The most important security headers<\/h2>\n<div class=\"hkb-tbl\">\n<table>\n<thead>\n<tr>\n<th>Header<\/th>\n<th>What it does<\/th>\n<th>Suggested value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Strict-Transport-Security (HSTS)<\/td>\n<td>Forces the browser to always open your site over https.<\/td>\n<td><code>max-age=31536000<\/code><\/td>\n<\/tr>\n<tr>\n<td>X-Content-Type-Options<\/td>\n<td>Stops the browser guessing file types and running an uploaded file as a script.<\/td>\n<td><code>nosniff<\/code><\/td>\n<\/tr>\n<tr>\n<td>X-Frame-Options<\/td>\n<td>Stops your pages being shown in a frame on another site to trick visitors into clicking.<\/td>\n<td><code>SAMEORIGIN<\/code><\/td>\n<\/tr>\n<tr>\n<td>Referrer-Policy<\/td>\n<td>Controls what part of your page URL is sent when visitors go to another site.<\/td>\n<td><code>strict-origin-when-cross-origin<\/code><\/td>\n<\/tr>\n<tr>\n<td>Permissions-Policy<\/td>\n<td>Turns off browser features you do not need, such as camera and location.<\/td>\n<td><code>camera=(), microphone=(), geolocation=()<\/code><\/td>\n<\/tr>\n<tr>\n<td>Content-Security-Policy (CSP)<\/td>\n<td>Lists the sources allowed for scripts and images, making <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/xss-cross-site-scripting\/\">XSS<\/a> harder.<\/td>\n<td>Needs tuning for each site<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>How to add them<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Back up your .htaccess file:<\/b> From the cPanel File Manager in your site folder, so you can restore it if something breaks.<\/li>\n<li><b>Make sure your whole site works on https:<\/b> Before adding HSTS, because browsers will refuse the unencrypted version for a long time. Read <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/enable-https-on-your-website\/\">how to enable HTTPS on your website<\/a>.<\/li>\n<li><b>Add the lines at the top of the file:<\/b> Copy the lines below and save.<\/li>\n<li><b>Open your site and test key pages:<\/b> Home page, dashboard, contact form and checkout.<\/li>\n<li><b>Test the result:<\/b> A free tool such as <code>securityheaders.com<\/code> shows which headers are present and missing.<\/li>\n<\/ol>\n<pre class=\"hkb-code\">&lt;IfModule mod_headers.c&gt;\n  Header always set Strict-Transport-Security &quot;max-age=31536000&quot;\n  Header always set X-Content-Type-Options &quot;nosniff&quot;\n  Header always set X-Frame-Options &quot;SAMEORIGIN&quot;\n  Header always set Referrer-Policy &quot;strict-origin-when-cross-origin&quot;\n  Header always set Permissions-Policy &quot;camera=(), microphone=(), geolocation=()&quot;\n&lt;\/IfModule&gt;<\/pre>\n<div class=\"hkb-note w\"><b>Be careful with CSP:<\/b> a strict CSP can block analytics, payment and chat scripts. Start in report-only mode with <code>Content-Security-Policy-Report-Only<\/code>, and enforce it once you are sure.<\/div>\n<div class=\"hkb-note\"><b>If your site uses Cloudflare:<\/b> you can enable HSTS in the Cloudflare SSL\/TLS settings instead of the file. Do not set it in both places with different values.<\/div>\n<div class=\"hkb-hh\">\n<h2>How Hyyat Host protects your site<\/h2>\n<ul>\n<li>Our <strong>LiteSpeed<\/strong> and Apache servers read Header directives in .htaccess directly.<\/li>\n<li>A <strong>free SSL certificate<\/strong> is issued automatically on most plans, and it is required before HSTS.<\/li>\n<li><strong>ModSecurity<\/strong> and <strong>Imunify360<\/strong> rules complement security headers by blocking attacks at the server level.<\/li>\n<\/ul>\n<\/div>\n<h2>Frequently asked questions<\/h2>\n<div class=\"hkb-faq\">\n<details>\n<summary>Do security headers improve my Google ranking?<\/summary>\n<p>They are not a direct ranking factor, but they protect your visitors and reduce the chance of a hack that would hurt your visibility.<\/p>\n<\/details>\n<details>\n<summary>Is HSTS risky for my site?<\/summary>\n<p>Only if you add it before your whole site works on https. After that it is one of the most important headers.<\/p>\n<\/details>\n<details>\n<summary>Is there a WordPress plugin for security headers?<\/summary>\n<p>Yes, some security plugins add them. But adding them in .htaccess is lighter and also covers static files.<\/p>\n<\/details>\n<\/div>\n<div class=\"hkb-rel\"><b>Related guides<\/b><\/p>\n<ul>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/xss-cross-site-scripting\/\">What Is an XSS Attack? Cross-Site Scripting Explained and How to Prevent It<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wp-config\/\">How to Protect wp-config.php in WordPress: 7 Steps to Secure Your Most Important File<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/what-is-an-ssl-certificate\/\">What Is an SSL Certificate and How Does It Work?<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-website-from-hacking\/\">How to Protect Your Website from Hacking: 10 Practical Steps<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.hyyat.com\/en\/kb\/website-protection\/\">All website security guides \u2192<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In shortSecurity headers are lines the server sends with every page, asking the browser to behave more safely: always open your site over https, never show your site inside other sites, never guess file types, and only load scripts from approved sources. You add them with a few lines in .htaccess and test them with [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"_templately_pack_id":"","_templately_imported_at":"","_templately_source":"","_templately_import_session_id":"","footnotes":""},"doc_category":[2744],"doc_tag":[],"class_list":["post-18932","docs","type-docs","status-publish","hentry","doc_category-website-protection"],"year_month":"2026-10","word_count":540,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"ahmed fathy","author_nicename":"ahmed-fathy","author_url":"https:\/\/www.hyyat.com\/en\/author\/ahmed-fathy\/"},"doc_category_info":[{"term_name":"Website Security","term_url":"https:\/\/www.hyyat.com\/en\/kb\/website-protection\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/comments?post=18932"}],"version-history":[{"count":0,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18932\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media?parent=18932"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_category?post=18932"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_tag?post=18932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}