ShoutMeLoud – Shouters Who Inspire

Superlinks
≡ Menu
≡ Menu

How To Block IP Address Using .htaccess method

TA
How To Block IP Address Using .htaccess method

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 thumb2

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.

<Limit GET POST PUT>
order allow,deny
allow from all
deny from 12.345.67.890
</Limit>

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.

<Limit GET POST PUT>
order deny,allow
deny from all
allow from 12.345.67.890
</Limit>

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

<Limit GET POST PUT>
order deny,allow
deny from all
allow from 12.345.67.890
allow from 890.67.345.12
</Limit>

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.

 

  • Author Bio

  • Latest Post

Article by S.Pradeep Kumar

S.Pradeep has written 1 articles.

If you like This post, you can follow ShoutMeLoud on Twitter. Subscribe to ShoutMeLoud feed via RSS or EMAIL to receive instant updates.


    { 2 comments… add one }

    • jaganmangat

      hey thanks for this post pradeep ,i was searching for this and got it……

      Reply
    • Robin

      Generally i use .htaccess to restrict folder access to certain ip addresses. its a great tool.

      Reply

    Leave a Comment