Replace SetEnvIf with RewriteRule to block bad clients

Situation:

We use "SetEnvIf" in Apache to deny access to our site based on the user-agent. This does not work with LiteSpeed.

For example:

SetEnvIfNoCase User-Agent "^WebZIP" bad_bot
SetEnvIfNoCase User-Agent "^Xaldon WebSpider" bad_bot

deny from env=bad_bot

Is there any way to make this work in LiteSpeed?

Solution:

Just use a rewrite rule for this.

RewriteCond %{HTTP_USER_AGENT} ^(WebZIP|Xadon WebSpider) [NC]
RewriteRule .* - [F]

  • Rewrite Rules, User-Agent
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How do I enable GEOIP function for vhosts from httpd.conf?

You should configure your GeoIP database from the LiteSpeed Web Server web console, make sure to...

How do I switch to LiteSpeed?

Migration: https://docs.litespeedtech.com/cp/cpanel/switch-apache/Installation:...