3 Must Apply Security Tips for WordPress

by Daniel in — 49 Comments — Updated — Reading Time: 2 minutes

Background Image

Today I was reading through my RSS feeds and I came across a very interesting post from Matt Cutts. Basically he was describing 3 (plus a bonus) tips to secure your WordPress install. I was already using two of them, but the first one was new to me, and looks like it is the most effective one as well.

1. Secure the /wp-admin/ directory

You probably know that most of your WordPress sensitive information is stored in the /wp-admin/ folder. Right out of the box, WordPress leaves that folder open, so people can access these files if they know what they are doing.

Matt suggests to place a .htaccess file inside the /wp-admin/ folder to block the access to all IP addresses, except yours. Here is the code you need to put in the .htaccess file:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Example Access Control"
AuthType Basic
order deny,allow
deny from all
allow from xx.xx.xx.xx
allow from xx.xx.xxx.xx

2. Hide your plugins

Many WordPress plugins come with bugs and vulnerabilities that can be exploited to damage your website. The last thing you want, therefore, is other people being able to know what plugins you are using.

If you visit the folder /wp-content/plugins/ on most blogs, however, you will be able to see all the plugins that are being used. In order to hide that list you just need to create an empty index.html file and drop it there.

3. Keep up with patches and updates

Most bloggers probably carry out this tip already. Just keep your WordPress updated and you should be fine. Matt suggests subscribing to the WordPress Development Blog.

The final bonus tip was just to delete the meta tag that reveals your WordPress version on the header of your site.

Do you know any other security tips that WordPress users should apply?

Update: Browsing on the Internet I also came across a WordPress plugin called Login LockDown. Basically it will track down login attempts to your site, and if there are too many of them coming from the same IP address on a short period of time the plugin will disable the login function for that IP range. Useful to avoid people trying to brute force your password.

Share this article

49 thoughts on “3 Must Apply Security Tips for WordPress”

  1. Three things you need to consider when using WordPress… security, security, security.
    Three great tips that could perhaps be explained in a little more detail.

  2. Thank you, I had been googling all the security problems that wordpress had to figure out how to fix it. I love wordpress, but the fact that anyone can hack into my site or edit something scares me, especially if I spend 100’s of hours building up my site.

  3. Thanks for the tips and comments. I just thought about the dynamic IP for my broadband… So tips no. 2 and 3 are the easiest to apply.

  4. I tried the htaccess and stumbled into an odd error! I couldn’t use the Plugin automated service that is in the admin of a WP Blog. It told me I had no permission!

    When I deleted it, I was able to install my plugins. 🙂 Just something to look out for? 🙂

  5. Hi!

    My IP changes every time i restart my broadband modem. what should i do to prevent hacking on my wordpress install? need help on this issue.


  6. Hi!

    My IP changes every time i restart my broadband modem. what should i do to prevent hacking on my wordpress install? need help on this.

  7. Thanks for you information…

    But this is more secure than the above code

    # -FrontPage-

    Options None

    order deny,allow
    deny from all
    allow from all
    require group authors administrators

    order deny,allow
    deny from all

    AuthType Basic
    AuthName yourwebsite.com
    AuthUserFile service.pwd //Example /home/usename/public_html/_vti_pvt/service.pwd
    AuthGroupFile service.grp //Example /home/username/public_html/_vti_pvt/service.grp


  8. Thanks for the security heads-up. We haven’t really thought about it til we saw this post.

    FYI – Matt’s post has an update where Joshua Slive pointed out that the .htaccess file shouldn’t have a around the IP addresses. That would have allowed IP addresses to POST, for example.

    We have a dynamic IP where the last digit of our IP address changes. There are about four or five different XX.XX.XXX.* address that we get with our ISP.

    We found that if we just drop the last number, we’re still able to access our wp-admin folder, but if we use an anonymous proxy and try to access it from an IP address in Germany, it won’t get in.

    Can anyone else verify that this works for dynamic addresses?

    allow from xx.xx.xx
    allow from xx.xx.xxx


  9. What happens if you have other authors writing posts. Will point number 1 affect their ability ot login and post topics? I mean if their IP isn’t added to the file.

  10. Jaan and Hendry,

    Thanks for the reminder on the Options -indexes. That works the easiest for managing, without having to add index.php or index.html files in folders.

  11. Regarding number 2, I’d recommend to disable directory index on all directories by placing the a line in .htaccess in the root directory:

    Options -Indexes

    This way, the option is off for the whole domain.

    While restricting access to wp-admin is useful it is not for people who don’t have static IP.

  12. “Do you know any other security tips that WordPress users should apply?”

    1. Change the default DB prefix (wp_).
    2. Hide your entire install.
    3. Matt’s bonus tip was a bit off. You can still get his version info. Just edit your wp-includes/version.php to hide it correctly.

    Info on how to hide your install and all the rest of this can be found here.

  13. “Matt suggests to place a .htaccess file inside the /wp-admin/ folder to block the access to all IP addresses, except yours.”

    What if I have a dynamic IP?

    And what if I access my admin through 2 different PCs with 2 different internet connections…

  14. Regarding .htaccess and IP Blocking: An alternative method is to use htaccess password – that way you can access it anywhere and not have it restricted to an IP. It pops up with a login box when you try to access the folder.

    There even a wordpress plugin to do it (I havent tested it)

  15. If you have control over your site’s httpd.conf, it is probably a good idea to deny index listing by default. Under your DocumentRoot directive, change your ‘Options’ to include ‘-Indexes’ (exactly as others have specified for .htaccess above).

    Example (angle brackets changed so they don’t mess up this comment):

    [Directory “/var/www/html/yoursite”]
    Options -Indexes

  16. @Mikhail: There is always a way around a security measure. They are just designed to thwart a percentage of the hackers. Thanks for the tip, though. I placed that index.php file in all the subfolders of the plugin directory. At least for the moment I am not exposed in the Akismet directory.

  17. Thanks for the tips! There are good reasons for hardening your WordPress install. WordPress stores passwords in the database as hash made from the password. A common Unix practice is to add random seed to the hash but WordPress does not do this. Should the password hash be revealed it could even be revealed by googling the hash!

  18. Right, but when the user clicks on the image he would be directed to the wp-content folder on your blog. If you block that he would see a 404 page, won’t he?

  19. Daniel that should not be a problem at all. Google doesnt find the images by browsing through folder access they find them through links on the pages themselves which would still work fine.

  20. I wonder if you can specify IP ranges for tip number 1. This would solve the problem for people with dynamic IP addresses.

    Well, you would still be vulnerable to people close to your IP class, but that reduces the risk greatly already.

  21. Great tips. Without a static IP address tip #1 is difficult to implement. I already made the change you suggested in tip #2, but added a bit of an informational message to the index.php file that I dropped into the plugin folder.


Leave a Comment