How To Block IP Address Using .htaccess method

How To Block IP Address

We have already covered some interesting topics on wordpress .htaccess hacks.

This post can be used for wordpress or for any website, by editing your .htaccess file. If you are not familiar with .htaccess file, refer to above mentioned post or get in touch with your hosting CC. wordpress_logo

If you are receiving Spam comments and other such activities from some person at a specific IP address, then you can easily deny access to your site by creating .htaccess file with the below mentioned code in it.

How To deny I.P. access to your Website using .htaccess File:

First identify the IP address of that visitor. There are two methods for this (I prefer these) :

  • If that visitor already commented in your blog, then you can find that person’s IP address easily from your WP dashboard.
  • Use StatCounter for finding the IP addresses.

Create .htaccess file and type the following code in it.

order allow,deny
allow from all
deny from 12.345.67.890

Here is 12.345.67.890 is the IP address of the person you want to block. You can replace this with your visitor IP address. Allow Visitors From Specific IP Address Using .htaccess

By this simple hack in your .htaccess file, you can block access to your blog from every IP addresses except the IP addresses you specified in the code.

It is used mostly when your blog is under construction and you don’t want your readers to see the site until it is over or even search engine spiders indexing problems.

order deny,allow
deny from all
allow from 12.345.67.890

Note that   each IP address is placed on a new line.

order deny,allow
deny from all
allow from 12.345.67.890
allow from 890.67.345.12

Replace the given IP address with your desired IP address.

If you like this post and find it to be informative, don’t forget to tweet it.


Subscribe on YouTube

Authored By
A simple kid next door of yours ! :)

2 thoughts on “How To Block IP Address Using .htaccess method”

Leave a Comment

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

Scroll to Top
Share via
Copy link