RSS Feed for This Post

Wordpress Tips : Block IP Addresses with .htaccess

Facing spam, hooliganism, vandalism or would you just prefer showing your blog to a select few? With this tutorial, it is very easy to block users with the IP you have defined, from accessing your blog. Please note, this is not possible on WordPress.com hosted blogs.

If the .htaccess file is not already created, you should create a file named .htaccess in your blog’s root directory (usually http://www.myblog.com/) and fill it with the content below:

order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx

Just change xxx.xxx.xxx.xxx to the ip you want to allow. You should now be able to access the file from http://www.myblog.com/.htaccess. Now your blog can only be accessed by the people with the IP you have set.

If you want to allow multiple IP addresses to access your blog, just create another record of IP like shown below:

order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
allow from yyy.yyy.yyy.yyy
allow from 111.111.111.111

To undo the changes, just delete the content from the .htaccess file or delete the .htaccess file itself. This trick is also helpful when you would like to do some updates for your blog. You can specify your IP to be allowed and then block all other IP addresses.

619 Read

Trackback URL