Add HTTP headers
You can add custom HTTP response headers to your WordPress.com site with the Redirection plugin or with a custom-redirects.php file in your site’s root folder. Use them to set security policies, control how search engines index your pages, and allow cross-origin requests.
About HTTP headers
HTTP headers pass extra information with each HTTP request and response. Response headers tell a visitor’s browser how to handle your site’s pages, such as whether to load them only over HTTPS, which sources scripts can load from, and whether other sites can show them in a frame.
WordPress.com already sends the headers most sites need, so you only need to add one when you want a specific behavior on your site.
List of common HTTP headers
The following table lists common HTTP headers you can add to your site. For every header and its accepted values, see the HTTP headers reference on MDN.
| Header | Description |
|---|---|
| X-Robots-Tag | Indicates how a web page will be indexed within public search engine results. The HTTP header is effectively equivalent to <meta name="robots" content="...">. |
| Access-Control-Allow-Headers | Used in response to a preflight request, which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request. |
| Access-Control-Allow-Methods | Specifies one or more methods allowed when accessing a resource in response to a preflight request. |
| Access-Control-Allow-Credentials | Tells browsers whether to expose the response to the frontend JavaScript code when the request’s credentials mode (Request.credentials) is include. |
| Access-Control-Allow-Origin | Indicates whether the response can be shared with requesting code from the given origin. |
| Access-Control-Expose-Headers | Allows a server to indicate which response headers should be made available to scripts running in the browser in response to a cross-origin request. |
| X-Frame-Options | Indicates whether or not a browser should be allowed to render a page in a <frame>, <iframe>, <embed>, or <object>. Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites. |
| X-XSS-Protection | Deprecated and non-standard. Internet Explorer, Chrome, and Safari once used this header to stop loading a page when they detected a reflected cross-site scripting (XSS) attack. In some cases the header can create XSS vulnerabilities, so use Content-Security-Policy instead. |
| X-Content-Type-Options | Indicates that the MIME types advertised in the Content-Type headers should be followed and not be changed. The HTTP header lets you avoid MIME type sniffing by saying that the MIME types are deliberately configured. |
| Strict-Transport-Security | Informs browsers that the site should only be accessed using HTTPS and that any future attempts to access it using HTTP should automatically be converted to HTTPS. |
| Referrer-Policy | Controls how much referrer information (sent with the Referer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML. |
| Content-Security-Policy | Allows website administrators to control resources the user agent can load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints. This helps guard against cross-site scripting attacks. You can set this header with the Redirection plugin or with custom-redirects.php. |
Add HTTP headers to your site
You can add a header with the Redirection plugin, which needs no code, or with a custom-redirects.php file that you edit over SFTP.
Add HTTP headers with a redirection plugin
The Redirection plugin can add HTTP headers without creating any redirects, so your pages are not redirected. A header with the site location applies to every request on your site.
To add a header, install the Redirection plugin, then follow the plugin’s guide to adding HTTP headers in its site options. Some headers can’t be changed on WordPress.com, even when the plugin lists them.
Header changes can take some time to appear on your live site. To see them sooner, clear your site’s cache and your browser cache.
Add HTTP headers with PHP code
This feature is available on sites with a paid WordPress.com plan once the site’s hosting features are activated.
To add headers without a plugin, create a custom-redirects.php file in your site’s root folder. Headers you set in this file with the PHP header() function are sent with your site’s pages.
To add headers with custom-redirects.php, take the following steps:
- Connect to your site with SFTP. For connection details, see Use SFTP on WordPress.com.
- Open the
htdocsfolder, which is your site’s root folder. - Create a file named
custom-redirects.php, or open it if it already exists. - Add one
header()call for each header, as in the following example:
<?php
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: SAMEORIGIN');
header('Referrer-Policy: no-referrer-when-downgrade');- Save the file to the server.
Once the file is saved, check your response headers by running curl -I https://yourgroovydomain.com.
Last updated: November 20, 2026