2015-06-21 58 views
0

我有一個htaccess重寫規則代碼,它可以在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所有useragents。

如何讓重寫規則在litespeed上工作?

回答

2

不幸的是,LiteSpeed不支持.htaccess文件中的SetEnvIf*指令。作爲替代,您需要使用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] 
相關問題