Prevent access or auto-delete readme.html, license.txt, wp-config-sample.php

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
    </files>

So, to block readme.html you do this:

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

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.

Leave a Comment