Block HTTP request based on user agent - browser used

If you need to block a user agent / bot / browser from your site, you can do so with a .htaccess rewrite -- note this applies to apache web servers and nginx would have its own method.


RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} botName [NC]
RewriteRule .* - [F,L]

 

Change "botName" to part of the user agent shown in access logs. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

SMTP Authentication via Scripts

Using SMTP authentication for your scripts, like you would with a mail client, is important for...

Sending mail via PHP / sendmail

Using PHP's mail() function and/or sendmail will sometimes cause anti-spam filters to filter out...

Which PHP versions do you support on shared hosting?

We currently support the following PHP versions on our shared hosting servers: 5.6 7.1 7.2...

How to create a .htaccess file

Creating a .htaccess is easier then it sounds. You can create an .htaccess file in any text...

Force https via htaccess

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]