0

我有一个适用于 Apache 但不适用于 litespeed 的 htaccess 重写规则代码。

<Files "bg.js">
SetEnvIfNoCase User-Agent .*autoit.* search_robot
Order Deny,Allow
Deny from All
Allow from env=search_robot
</Files>

我想阻止所有用户代理,除了那些不区分大小写的用户代理autoit

如何让重写规则在 litespeed 上工作?

4

1 回答 1

3

不幸的是,LiteSpeed 不支持文件中SetEnvIf*的指令.htaccess。作为替代方案,您需要使用mod_rewrite

RewriteEngine On

# Check that the request is for /bg.js
RewriteCond %{REQUEST_URI} ^/bg.js

# Check that the request matches an existing file
RewriteCond %{REQUEST_FILENAME} -f

# Check that the user agent does not contain autoit
RewriteCond %{HTTP_USER_AGENT} !autoit

# If all conditions above are met, then deny access to this request
RewriteRule ^ - [F,L]
于 2015-06-22T04:31:16.380 回答