Many webmasters take spam visitors as a headache problem and most of them are looking forward to finding out a good way to enhance their sites security. In fact, what they need to do is just blocking malicious IP addresses in their WordPress sites. To help them solve this problem easily, in the article below, we have introduced two methods, using a plugin and using .htaccess respectively to ban some IP addresses.
Use a Plugin to Block IP Addresses
A good plugin should come with high performance, here we recommend LionScripts: IP Blocker Lite which helps you ban unlimited malicious addresses that visit you websites. Moreover, the plugin will automatically offer a web page with nothing or a predefined message to those visitors who are blocked.
Enter LionScripts: IP Blocker Lite into the WP admin search box and then find out the right one. Click “Install Now” and remember to activate the plugin. We have also developed an article to teach people how to install a WordPress plugin, you can follow the steps to complete the whole process. After that, you can see LionScripts on the list and you will go into the settings page automatically.
At first, pay attention to your current IP address that appears in red and don’t block it, following the reminding. Then choose Block IPs Manually option among the 3 settings.
This option is very helpful for blocking IP addresses in small scale. You should enter the IP address manually in the “Add New IP” box. Then, click “Add” and you will see the blocked IP addresses in the list. Remember to click “Save Changes”.
The second option is helpful to upload IP addresses in CVS format. You can select this option if needed, and then click “Choose File”. Click “Upload CSV” to complete the uploading. However, if you don’t know the CVS format, you can look for details by clicking “Download Sample CSV”.
With the third option, you can download the blocked IP addresses in CSV format.
After doing the three settings above, choose what to be showed on web page when the blocked IPs try to access to your site . Here, we recommend you choose both “Display blank page to the Banned User” and “Proudly display that you are using IP Addresses Blocker”.
What’s more, you can also have a try with these plugins: Limit Attempts, IP Geo Block and IP Blacklist Cloud. All the three plugins are widely used for enhancing website security.
How to Use .htaccess to Block IP Addresses?
Using .htaccess is another method to block IP addresses. You need to add the IP addresses that you want to block into the .htaccess file. Now, follow the steps below.
Log into cPanel and click “File Manager”. Find out the correct document root and then pick out the .htaccess file among many files. Right-click the file and choose “Edit” to open it in an editor.
Now, you need to place the text in following picture at the beginning of the file. Besides, you need to use “xx.xx.xx.xx” to replace an IP address to be blocked from accessing your site. You are also able to block more IPs in a proper order. Note that there should be a separate line in each 2 IPs.
However, if you want to block the address in a range of IP addresses, such as from aa.bb.cc.1 to aa.bb.cc.254, you need to add the IP addresses in the format “aa.bb.cc”. Click “saves” to take effect.