By: Prem Tiwari | Last Updated:
In this tutorial i have shared how to block visitors from visiting your website using htaccess. Lets assume someone is spamming your website from specific IP address to loose your website’s traffic.
Now you can block visitors to access your website from IP address using htaccess code. below is the simple code to block visitor spamming your website.
Copy paste below code to a text file and upload it to the root directory of your website. Then rename it to “.htaccess”. You can also generate htaccess file from this tool click here. You can also add multiple IP addresses in below code
Deny from xxx.xxx.xx.xxx by copy the same line of code.
# allow all except those indicated here
Deny from xxx.xxx.xx.xxx
You can also block IP address by logging into Cpanel.
Step 1) Login to cPanel and search IP Blocker, click on IP Blocker option.
Step 2) Enter IP address or domain name which you want to block.
Step 3) Click the Add button.
Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby. View all posts by Prem Tiwari