Step::1 Login to your cPanel and click File manager.
Step::2 Go inside public_html directory where you will find the .htaccess
Step::3 Now, we need to restrict bots by adding some codes to the .htaccess file. Right click on .htaccess file and choose the Edit option.
Add the following lines of code to your .htaccess file to restrict bots from your site
#Block Bad User Agents
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^SpiderMan[OR]
RewriteCond %{HTTP_USER_AGENT} ^voyager[OR]
RewriteCond %{HTTP_USER_AGENT} ^WaveFire
RewriteRule .* - [F,L]
(In the above code, SpiderMan, voyager and Wavefire are the bots. These can be replaced by the bots you want to block.)
The last line of code requests the server to give a 403 error to the bots in the code.
Step::4 You can also restrict the access if you know the IP address of the bot.
You can list the IP addresses in the .htaccess file
You can add the IP address or the range of IP address of the bot that you want to block.
#Restrict IP of bots
Deny from 123.123.45.184
Deny from 123.123.99.952
#Restrict IP range of bots
Deny from 123.123.123.0/24
Step::5 Finally click on Save Changes tab and Close the Editor.
By following the steps mentioned, you can make your site safe from malicious bots to access your site.
Visit the Blog for more details. You can also watch the video here.