04
May
2010

Allow WordPress admin login from specific IPs or IP range

Posted in: WordPress Security , No Comments

restrict login Its good security practice to allow admin logins from specific IPs only. So, even if your WordPress admin login details is hacked, you are still safe. Hackers will not be able to login in admin area of WordPress, and your blog is safe.

This can be achieved easily by using a .htracess file in wp-admin folder.
How can I allow admin login from one specific IP
Open notepad and copy paste following codes.

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Admin Access Control"
AuthType Basic

order deny,allow
deny from all
allow from xx.xx.xx.xx

NOTE: Change xx.xx.xx.xx to your IP.
Upload this text file in wp-admin folder and rename it to .htaccess
Done!!

Lets say your IP is 122.162.160.9
If your IP is 122.162.160.9, you should replace xx.xx.xx.xx in above code to 122.162.160.9
Now only person from 122.162.160.9 will be able to login in wordpress admin panel.

How can I allow admin login from many specific IP
If you want to allow login from multiple specific IPs, you just need to add those IPs in .htacess file we made above.
Something like this:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Admin Access Control"
AuthType Basic

order deny,allow
deny from all
allow from aa.aa.aa.aa
allow from bb.bb.bb.bb
allow from cc.cc.cc.cc
allow from dd.dd.dd.dd

Note:

Replace aa.aa.aa.aa, bb.bb.bb.bb, cc.cc.cc.cc, dd.dd.dd.dd to IPs which you want to allow.
Like this, you can allow multiple IPs to login as admin.

How can I allow admin login from a IP range
This is common question asked by many wordpress users. Many people like me are on DSL connection and have dynamic IP. Our IP changes everytime, we start computer or restart modem. So, people on dynamic IP need to allow a specific IP range.

You need to use below code for .htaccess file to allow a complete IP range.

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Admin Access Control"
AuthType Basic

order deny,allow
deny from all
allow from 67.22.xx.xx

Note:

In above code, you need to change just first two place of IP and leave xx.xx
Lets say your IP current IP is 122.45.673.46
Then you should use like 122.45.xx.xx

Warning

When editing or modifying the .htaccess file of your WordPress blog, make sure to always have a backup that you can restore in case of something went wrong.

If you still have confusion, please let me know via comment.

browse premium wordpress themes

About the Author

Name: Ravi Shekhar
I love blogging and designing WordPress and Drupal themes.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>