我有一个htaccess重写规则代码,适用于Apache但不适用于litespeed。
<Files "bg.js">
SetEnvIfNoCase User-Agent .*autoit.* search_robot
Order Deny,Allow
Deny from All
Allow from env=search_robot
</Files>
我想阻止所有使用者,除了那些与autoit
不区分大小写的用户。
如何让重写规则适用于litespeed?
答案 0 :(得分: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]