Home > Wordpress > Protecting the WordPress wp-admin folder

Protecting the WordPress wp-admin folder

January 16th, 2007 Leave a comment Go to comments

After reading about greywolf’s blog being defaced as well as a few others, I thought I’d tighten up security a little. According to comments by shoemoney, it looks like the vulnerability is exposed by accessing some of the files contained within the /wp-admin folder. This should be fixed with the 2.0.7 WordPress upgrade [2.1 is also now available], however, let’s add a little extra security with a htaccess file. This will limit access to this folder by IP address. Any attempts at accessing any file within this folder will be greeted with a Forbidden error message.

I placed this file in the /wp-admin folder (DO NOT REPLACE/EDIT THE .htaccess FILE IN THE ROOT FOLDER OF YOUR BLOG)

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

Update: Note that this is was temporary fix until the next version of WordPress came out. If you do limit access to your wp-admin folder by IP address you may have to update it if your internet provider assigns you a dynamic IP address, you move to another location or you have authors at other locations.

You may also want to check out Michael’s Login Lockdown plugin which will prevent attackers trying to brute force their way in. Failed login attempts are recorded and after a set amount of failed logins, it blocks an IP range for 1 hour by default.

Categories: Wordpress Tags:
  1. jason
    April 9th, 2007 at 15:11 | #1

    What do I name the file and what does this do exactly for the wp-admin folder??

  2. April 9th, 2007 at 19:15 | #2

    Jason: the file needs to be named “.htaccess” without the quote marks. It prevents hackers trying to get into your WordPress administration area by only allowing access to the listed IP addresses. This was really intended as an emergency/temporary solution when someone found a WordPress exploit, however, if you’re running the latest version you should be safe from that particular issue.

  3. Max
    June 13th, 2007 at 06:58 | #3

    Nice

  4. July 19th, 2007 at 08:59 | #4

    Hey Guys,

    Nice tips, I will launch a blog based at my site… I will apply some of…

    Take care…

  5. August 11th, 2007 at 02:10 | #5

    Great article and useful, tnx dude.

  6. August 17th, 2007 at 01:45 | #6

    I’ve read the commnets of Matt Cutts about WordPress – he says that keeping the .htaccess file in root directory is unsafe. How can it be moved to /wp-admin/ directory?

  7. August 17th, 2007 at 10:14 | #7

    said

    WordPress uses it’s own .htaccess in the root of the blog – do not edit or move that file.

    The tips here are to create a new .htaccess file and store it in the wp-admin folder.

    Do not edit or overwrite the .htaccess file in the root of your blog as you may completely break your blog.

  8. October 2nd, 2007 at 03:34 | #8

    That is actually good advice reuben, god I wish I would have know that a few months ago, it would have saved me some pain.

  9. November 21st, 2007 at 23:54 | #9

    I am wondering how to separate wp-admin and place it in another server instead being on one server with the display.

  10. March 23rd, 2008 at 14:27 | #10

    u know i am trying to do that but for some reason i am geting the right path…i am tryig to protect my admin panel…i have read many htacess but still for some resaon not sccessful

    i dont knw how to go about doing it

    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

    also with ur method with ip if they have dynamic ip how would u go about doing that

  11. BOB
    February 10th, 2009 at 18:58 | #11

    Reubenyau

    Im using a hosting plan that allows multiple domains, The problem im having is this htaccess isnt working on this peticular plan, Im guessing its something to do with the dev/null/ maybe

    It works on single domain plans though, as ive tested it

    Please get back to me, I need to protect my sites.

  12. February 27th, 2009 at 17:50 | #12

    I cannot emphasise enough how important it is to protect your admin directory. Given this post relates to version 2.1 don’t think the latest version (2.7) should take care of this security issue. WordPress is pretty good out of the box but addtional protection in the form of htaccess file is a must have no matter what version you are using.

  13. June 14th, 2009 at 22:53 | #13

    Thanks for the tips on how to fix this issue with wordpress. Till they launch their updated version this can keep things under control.

  14. joe
    September 30th, 2009 at 22:57 | #14

    I used the code below to protect wp-admin. Now all users who go to the main page are being prompted the the “WordPress Admin Access Control” password rather than the password assigned to their subscriber accounts. If they hit cancel several times, the login page that uses the subscriber info appears. Any ideas?

    AuthName “WordPress Admin Access Control”
    AuthType Basic
    AuthUserFile /homepages/**/********/htdocs/.htpasswd
    order deny,allow
    deny from all
    require valid-user
    # whitelist *****’s IP address
    allow from **.**.***.***
    Satisfy Any

  15. May 22nd, 2010 at 11:28 | #15

    Very good post, awesome read, thanks

  16. June 11th, 2010 at 03:25 | #16

    Super tips man. This will help me secure my blog more..

    Can also use wordpress secure connection plugin.

  17. August 15th, 2010 at 06:08 | #17

    I’ve created a small script which helps people without a fixed IP to get all network ranges of their provider. The output can be directly added to the .htaccess file. Here in Germany the script works well for bigger providers, I don’t know if it works in other countries. But I assume it does.

    The output of the perl script looks like:

    allow from XXX.X.XXX.0/24
    allow from XXX.X.XXX.0/24
    ….

    The script and some more explanation is available from:

    http://technitip.net/2010/08/how-do-you-protect-your-blog-from-hackers/

    It’s only needed to replace the netname within the script. On the page it described how to find out the dial-in netname from your provider.

    I hope it’s useful.

    Greetings from Germany,
    Harry

  18. April 6th, 2011 at 15:46 | #18

    So if I have wp 3.0 or above is any of this necessary?

  19. July 23rd, 2011 at 13:54 | #19

    Very useful tip! Thanks +1

  20. Rachel
    October 21st, 2011 at 15:41 | #20

    I’ve just used this because WordPress apparently still has security holes.

  21. November 13th, 2011 at 05:34 | #21

    This is little difficult for peoples with dynamic IP address. Login Lockdown seems better

  1. January 16th, 2007 at 23:33 | #1
  2. August 14th, 2007 at 09:57 | #2
  3. August 15th, 2007 at 02:25 | #3
  4. August 18th, 2007 at 18:40 | #4
  5. August 22nd, 2007 at 20:48 | #5
  6. September 12th, 2007 at 18:23 | #6
  7. September 21st, 2007 at 15:28 | #7
  8. January 18th, 2008 at 01:04 | #8
  9. January 23rd, 2008 at 20:42 | #9
  10. February 17th, 2008 at 19:12 | #10
  11. July 9th, 2008 at 10:04 | #11
  12. July 12th, 2008 at 16:46 | #12
  13. August 23rd, 2008 at 09:22 | #13
  14. September 30th, 2008 at 06:56 | #14
  15. October 4th, 2008 at 00:56 | #15
  16. October 9th, 2008 at 00:06 | #16
  17. March 9th, 2009 at 08:35 | #17
  18. March 19th, 2009 at 03:49 | #18
  19. April 7th, 2009 at 20:05 | #19
  20. April 18th, 2009 at 23:14 | #20
  21. April 25th, 2009 at 13:51 | #21
  22. May 21st, 2009 at 10:19 | #22
  23. August 12th, 2009 at 10:21 | #23
  24. August 25th, 2009 at 22:49 | #24
  25. October 5th, 2009 at 10:10 | #25
  26. October 6th, 2009 at 04:08 | #26
  27. November 1st, 2009 at 21:47 | #27
  28. November 12th, 2009 at 10:18 | #28
  29. November 23rd, 2009 at 00:06 | #29
  30. November 29th, 2009 at 09:41 | #30
  31. December 2nd, 2009 at 01:26 | #31
  32. December 30th, 2009 at 08:06 | #32
  33. December 31st, 2009 at 20:42 | #33
  34. January 7th, 2010 at 05:18 | #34
  35. January 9th, 2010 at 09:59 | #35
  36. January 12th, 2010 at 10:09 | #36
  37. January 20th, 2010 at 05:25 | #37
  38. January 27th, 2010 at 04:49 | #38
  39. February 2nd, 2010 at 01:40 | #39
  40. February 4th, 2010 at 04:47 | #40
  41. February 6th, 2010 at 02:50 | #41
  42. February 9th, 2010 at 05:32 | #42
  43. February 9th, 2010 at 14:11 | #43
  44. February 10th, 2010 at 04:58 | #44
  45. February 21st, 2010 at 04:12 | #45
  46. March 26th, 2010 at 22:20 | #46
  47. April 4th, 2010 at 11:39 | #47
  48. April 17th, 2010 at 10:03 | #48
  49. May 19th, 2010 at 10:25 | #49
  50. June 10th, 2010 at 04:50 | #50
  51. December 7th, 2010 at 01:45 | #51
  52. January 6th, 2011 at 21:10 | #52
  53. April 19th, 2011 at 12:58 | #53