Adding a security.txt file so a finder can reach you

To add a security.txt file, create a small plain-text file with a contact address, save it as security.txt, and publish it at https://yourdomain/.well-known/security.txt so it loads over HTTPS. That is the whole job, and for most sites it takes about ten minutes.

How to fix6 min read

A security.txt file is a quiet piece of good manners. It gives a security researcher, a customer, or a passer-by who spots a problem a clear, published way to tell you before they post it publicly or give up and move on. Our free scanner flags a missing one because the fix is easy and the upside is real: a friendly finder can reach the right inbox instead of guessing.

This page walks through the required fields, the expiry date that catches most people out, and exactly where to drop the file on Apache, Nginx and WordPress.

Why a security.txt file is worth ten minutes

Imagine someone notices your contact form leaks an error page, or that an old subdomain is still live. If they cannot find a way to tell you, they have three options: email a generic address and hope, post it publicly, or shrug and leave it. A published security.txt turns that guesswork into a direct line.

The format is a small open standard (RFC 9116). It does not add any protection to your site on its own. It simply advertises how to report a problem, which shortens the gap between someone spotting an issue and you hearing about it. That gap is often where small problems become public ones.

The fields to put in the file

The file is plain text, one field per line, in the format Field: value. A couple of fields are required, and a few extras make it genuinely useful.

At minimum include a Contact line and an Expires line. Keep it simple and avoid clever formatting: it is a text file, not a web page.

  • Contact: the address a finder should use, for example Contact: mailto:security@yourdomain.co.uk or a URL to a report form. You can list more than one Contact line in order of preference.
  • Expires: a date after which the file should not be trusted, written in full ISO format, for example Expires: 2027-01-01T00:00:00.000Z. This field is required by the standard.
  • Preferred-Languages: optional, for example Preferred-Languages: en, so a finder knows how to write to you.
  • Canonical: optional, the exact URL where this file lives, which helps confirm it is genuinely yours.
  • Policy: optional, a link to a page describing how you handle reports.

The expiry gotcha

The Expires field trips people up more than anything else. It is mandatory, and if the date has passed, a careful finder is told to treat the file as stale and may not trust the contact details. A file you published two years ago with a one-year expiry is effectively dead.

Set the date a sensible distance ahead, commonly six to twelve months, and put a reminder in your calendar to refresh it before it lapses. Do not set it decades into the future to avoid the chore: a very distant expiry defeats the point of the field, which is to prove the file is still maintained. A short, honest window that you actually renew is better than a long one you forget.

Free, instant, no account

See your site's security grade in seconds.

Free, instant, and no account needed to see your grade.

Scan my site free

Plain-English A to E grade in about 10 seconds. No account needed to see it.

Where to put the file on Apache, Nginx and WordPress

The location matters as much as the contents. The file must load at /.well-known/security.txt over HTTPS. A copy at the site root (/security.txt) is allowed as a fallback, but the well-known path is the one tools and finders check first.

How you place it depends on your setup.

  • Apache: create a .well-known folder inside your web root (often public_html or the DocumentRoot), then place security.txt inside it. No special config is usually needed, though make sure the folder is not blocked by an existing rule.
  • Nginx: put the file in your site root under /.well-known/security.txt. If a location block already handles .well-known (for example for TLS certificate renewal), confirm it does not stop the file being served.
  • WordPress: the tidiest route is to upload the file over SFTP or your host file manager into a .well-known folder in the site root, alongside wp-config.php. Because WordPress rewrites most URLs, a real file on disk is more reliable than a page or post. Several small plugins can also generate one if you prefer not to touch files.

Check it is live, and know what the scan does not tell you

Once published, open https://yourdomain/.well-known/security.txt in a browser. You should see your plain text, not a 404 and not your normal site design. If you see an HTML page, the request is being rewritten and the file is not being served from the right place.

Our scanner checks one specific thing: that the file exists at the correct path and loads. It does not read your email, confirm the contact address actually works, or judge whether the fields are perfect. So after publishing, send a quick test message to whatever address you listed and make sure a real person receives it. A security.txt pointing at a dead inbox is worse than none, because it looks maintained when it is not.

One more honest note: publishing this file fixes nothing else on your report. It is a small, standalone piece of good practice. The other findings, such as missing headers or an expiring certificate, still need their own attention.

Publish a plain-text security.txt at /.well-known/security.txt over HTTPS with a working Contact line and a future Expires date you actually renew, then send a test email to confirm the inbox is real.

Common questions

Where exactly should the security.txt file go?
At https://yourdomain/.well-known/security.txt, served over HTTPS. That means a folder named .well-known in your web root with security.txt inside it. A copy at the site root (/security.txt) is accepted as a fallback, but the well-known path is checked first by tools and finders.
Is the Expires field really required?
Yes. Under RFC 9116 the Expires line is mandatory, written in full ISO date-time format. If the date has passed, a careful finder is told the file may be stale and might not trust it. Set it six to twelve months ahead and renew it before it lapses.
Does adding a security.txt file make my site more secure?
Not on its own. It does not block attacks or fix any other finding. It simply advertises how someone should report a problem to you, so a friendly finder can reach the right inbox quickly instead of guessing or going public.
What should the Contact line point to?
An address a finder can actually use: a mailto link such as mailto:security@yourdomain.co.uk, or a URL to a report form. Use an inbox a real person monitors, and send a test message after publishing, because the scan checks the file exists but cannot confirm the address works.
How do I add it on WordPress without breaking things?
Upload a real security.txt file over SFTP or your host file manager into a .well-known folder in the site root, next to wp-config.php. A file on disk is more reliable than a page or post because WordPress rewrites most URLs. Small plugins can also generate one if you prefer.
How do I know it worked?
Open the well-known URL in a browser. You should see your plain text, not a 404 and not your normal themed page. If an HTML page loads instead, the request is being rewritten and the file is not being served from the correct location.

How safe is your website?

A free A to E grade in about 10 seconds. No account needed.

Check my site