Just a quick question that might help a tad bit with security. I noticed that the readme.html file has the version number listed. It reappears after each upgrade and so do the licence.txt, and wp-config-sample.php.

Is there a easy way to have WordPress auto remove these files after an upgrade?

I already block the version number from showing in the meta tags, rss feeds, atom, etc.

I know this type of security isn't exactly that much helpful, but just thought it might be a tiny start. I heard that people can simply check the version of jQuery that is included in WP-includes and cross reference which version of WP shipped it.

4 Answers 4


You don't really need to remove these files. It's much easier to just block access to them. If you are using pretty URL's you already have an .htaccess file. Using .htaccess to block the files is secure and you only have to add a directive once.

Blocking files is done by adding a directive to .htaccess like this:

    <files filename.file-extension>
         order allow,deny
         deny from all

So, to block readme.html you do this:

    <files readme.html>
         order allow,deny
         deny from all

Do the same with the license file or any other file you want to prevent anyone from accessing. Just open .htaccess in Notepad or any other basic text editor, add the directives and save, making sure that the text editor keeps the file name exactly - without any .txt on the end.

  • 1
    This is actually the option I ended up going with. It works perfectly. May 16, 2011 at 4:49
  • 2
    Beware, that the above Syntax is only valid up to Apache 2.2! Afterwards use Require all denied (replacing those inner 2 lines) for Apache 2.4 and above. More Details here
    – Frank N
    Mar 7, 2017 at 7:00

Here is my take:

RewriteRule (?:readme|license|changelog|-config|-sample)\.(?:php|md|txt|html?) - [R=404,NC,L]
  • 404 (not existing) rather than 403 (forbidden) to avoid any clue about existence.
  • also in subfolders (i.e. themes and plugins, which might offer attack opportunities)
  • case-insensitive, extension-flexible, also catches README.html, or license.html (feel free to add typical suspects like changelogs|faq|contributing)

Personally, I would also block:

RewriteRule \.(?:psd|log|cmd|exe|bat|c?sh)$ - [NC,F]


  • '?:' just declares the bracket to be non-matching (no importance).
  • requires RewriteEngine to be on (it most likely is. it would be rare, to use wordpress without... (ugly permalinks, etc...)).
  • insert before the # BEGIN WordPress section in your .htaccess
  • Any advantage to using a RewriteRule vs FilesMatch? Sep 27, 2023 at 19:10

Edit : you can also try these

  • Thanks, I figured out the php unlink feature and it works, but one issue. The hook you provided seems to execute by simply visiting the Updates section under Dashboard. Is there another hook for after the upgrade has occured? Dec 15, 2010 at 20:16
  • 1
    ill take a look and let you know
    – Atif
    Dec 16, 2010 at 10:23
  • @Sahas @atif089 Did you manage to get this to work?
    – INT
    May 12, 2011 at 10:38
  • Instead of delete (in case you want to actually read the readme!) you can use this in your function chmod("/path/to/readme.txt", 0640);
    – Bysander
    Oct 10, 2016 at 12:07

2023 Solution

If you use Apache, currently on 2.4.5x version, as your web server and would like to go down the ".htaccess" path, then here are some options (in addition to Frank's answer), to do so:

Returning "Forbidden" to the user:

In this case, "user"/"hacker"/"adversary"/"pentester" would figure out those files exist on your server but s/he doesn't have access to them!

<FilesMatch "(?:readme|license|changelog|-config|-sample)\.(?:php|md|txt|html?)">
      Require all denied

Returning "404" to the user:

In this case, "user"/"hacker"/"adversary"/"pentester", theoretically, would assume those files don't even exist on your server!

<FilesMatch "(?:readme|license|changelog|-config|-sample)\.(?:php|md|txt|html?)">
      Redirect 404

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.