How to Block IP Address from Website ( .htaccess / Cpanel)


Blocking IP address from your website or using cpanel can be done easily. Today we learn how to block Ip address from website as well as htaccess ip block. Before we get into blocking ip address, we shall discuss few important points to block Ip address.

You guys know well that wordpress blogs are hacked easily when compared to other platforms. Securing wordpress sites from hackers, staying safe in protecting our content and files is must. So, I was checking my gmail inbox and found a suspicious activity. A user with IP address xxx.xxx.xx.xx tried to hack my wordpress site with username admin and bloggerbulk. As per wordpress security tips concerned, using admin as username is really a bad idea. This is what that guy thought to hack my site. So always change your default username from “admin”. Now after finding which IP address is trying to hack your site..? Then we should block that Ip for our safety.

Inorder to block Ip address, I would list two methods first from cpanel and the other htaccess method. So let’s get into tutorial.

Block IP Address with Cpanel

I am using Hostgator now, if you are using bluehost or any other, almost the process is same. Log into your cpanel, under security section, click on IP Deny Manager, in next window you get option to enter Ip address for blocking.

block_ip_address_ip_deny_manager

Now, enter your victims IP you traced for suspicious activity and then click on add. You are done in blocking IP address.

using_IP_Deny_Manager_in_hostgator_to_block_Ip_address

Htaccess Ip Block

If you are looking for htaccess ip block method for blocking ip address, then look at below example code that should be added in your .htaccess file

 

order allow,deny
deny from 255.255.0.0
deny from 69.45.6.12
allow from all

The above is clear and almost you can understand. If not, here I go..

Deny from 255.255.0.0  :   This ip (255.255.0.0 ) will be blocked to view your site.

Deny from 69.45.6.12      :   This Ip ( 69.45.6.12.0 ) will be blocked to view your site.

Allow from all                         :   The rest of IP’s are allowed.

Now if you are looking to block all ip address except your, then look at below code

 

order allow,deny
allow from 49.12.11.2
deny from all

The above code should be added in your htaccess file and clear explaining, only the IP 49.12.11.2 would be able to access site and the rest of IP would be blocked. Note:  You need to replace this with your IP address.  “Deny from all” code will block all other IP’s except 49.12.11.2.  So if you found this tutorial helpful so comment and share it social media.

Article By Tharun

Hey! Tharun here. A Blogger makes blogging on wordpress tips, blogger tricks, SEO tricks, Android Apps, He love to share what he knows. Meet him at Facebook, Twitter. Get free Wordpress Installation Service Contact Here.

Comments

  1. says

    Hey Tharun,

    I use Cpanel to block IP addresses and I use it a lot in conjunction with the WordPress ‘Limit login attempts’ plugin. What I like about the plugin is that it sends me an email when someone is trying to login to my account along with the IP address. Once I have those IP addresses I can automatically plug them into my cpanel’s block ip address section and I’m done. Very useful.

    Thanks for posting this. It makes it easy for folks to know what to do to keep their blog secure.

    Blessings,
    Liz

    • says

      Hi Liz Madam,

      Good to see you here. Yes, even me too use, Limit Login attempts wordpress plugin to be secured from hackers. The best plugin, I feel about controlling login attempts. This post is just for beginners to learn how to prevent their blog for spammers.

      Thanks for commenting here. Hope you would be back.

      • Jon Adam says

        ‘Limit login attempts’ is this plug in free ?
        If this plug in is not free then you have done a very job . Actually , I use blogger for running my blog and did not know much . And at the moment , I am thinking to start a WordPress blog .
        I liked your very straightforward writing style , you don’t bother a reader with complicated words .

        • says

          Hi Jon Adam,

          Limit Login Attempts plugin is free to use. If you are looking for wordpress site establishing, I may help you in setting your site for almost free of cost. You can use the contact form if you interested.

          Thanks for commenting and your nice words.

  2. says

    Hi Tharun,

    I appreciate your taking time to write this article. It is going to save me a lot and thanks Liz for mentioning the Limit login attempts’ plugin. I came across it once but forgot the name.

    • says

      HI Shabir,
      Thanks for commenting. Surely we should take care of our blog. So better to block ip address from website or cpanel that you found doing some mischief thing against your blog with help of Limit Login Attempts wordpress plugin. Hope you would be back.

  3. Mazid Irshad Umar says

    Hello,

    What a wonderful tutorial on how to block IP address from website. There are many webmasters who share this kind of tutorial but don’t share in a good manner. They makes things complicated. I love your style how you shared everything in a good manner.

    Keep up your good work!

    Have a great day!

    Regards,
    MazidIrshad

Leave a Reply to Jon Adam Cancel reply