24/7 U.S. Support – 877-595-4482
This article will demonstrate various ways to block unwanted site visitors via your .htaccess file. This will allow you to block things such as specific IP ranges, or even bots that may be causing issues with your site by not adhering to your robots.txt rules. Follow along below as we describe different ways to block these unwanted visitors.
To be able to place the blocking code, you will need to know how to edit your .htaccess file, which is found in your cPanel File Manager. Once you have accessed the .htaccess file and opened the editor, you can then decide on which method you will use to block the visitors. Simply paste the appropriate code into the top of the .htaccess file to keep out the unwanted visitor.
If you know a visitor's IP address, you can block that single IP address with a simply line of code known as a deny. Below is an example of denying access to an IP address of 18.104.22.168.
You can also block an entire range of IP addresses. If you leave off the last set of numbers of the IP address (known as an octet), this will block the entire range of that octet. For example, 22.214.171.124 - 126.96.36.199 Below is a sample of the code you would place in your .htaccess file to do this.
This next method is a bit more complex. It first requires that the RewriteEngine be activated, then evaluates the user-agent string of the incoming request of the visitor. In the sample code, if the words Baiduspider or Yandex (which are bots for Chinese and Russian search engines, respectively) is in the user-agent, it activates the RewriteRule line of code, in which we send them a 403 (access denied) code.
|Email:||support@WebHostingHub.com||Ticket:||Submit a Support Ticket|
|Chat:||Click To Chat Now|