LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > [Resolved] Lightspeed and hosting provider - Fails

Reply
 
Thread Tools Display Modes
  #11  
Old 05-21-2010, 04:23 AM
brrr brrr is offline
Senior Member
 
Join Date: Aug 2007
Posts: 94
I am assuming this means directives like this in .htaccess will also fail to function under Litespeed:

Code:
BrowserMatchNoCase ^WWW-Mechanize BadRobot
BrowserMatchNoCase ^Xenu BadRobot
BrowserMatchNoCase "Y!OASIS/TEST" BadRobot
BrowserMatchNoCase "YebolBot" BadRobot
BrowserMatchNoCase "ZeW" BadRobot
BrowserMatchNoCase ^Zip BadRobot
BrowserMatchNoCase "ZmEu" BadRobot

<Files *>
Order Allow,Deny
Allow from all
Deny from env=BadRobot
</Files>
That could mean some hassles.
Reply With Quote
  #12  
Old 05-21-2010, 06:28 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,227
The rewrite equivalence:
Code:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^(WWW-Mechanize|Xenu|Zip) [OR,NC]
RewriteCond %{HTTP_USER_AGENT} .*(Y!OASIS/TEST|YebolBot|ZeW|ZmEu).* [NC]
RewriteRule (.*) - [F]
Reply With Quote
  #13  
Old 05-21-2010, 08:23 AM
brrr brrr is offline
Senior Member
 
Join Date: Aug 2007
Posts: 94
Thank you for that code NiteWave. Much appreciated. It will help out some users who relied on .htaccess under Apache to do bot-blocking.
Reply With Quote
  #14  
Old 05-22-2010, 05:15 AM
Morpheus Morpheus is offline
New Member
 
Join Date: May 2010
Posts: 8
Quote:
Originally Posted by NiteWave View Post
1)yes.if no "RewriteEngine On", RewriteCond or RewriteRule won't work and will be ignored. However, if .htaccess has no RewriteCond or RewriteRule, you needn't "RewriteEngine On".

2)I think the new way is more efficient and obviously. However, I haven't tested it so without hard evidence...
I think we almost got what we need but trying to be, I guess, backward compatable? This seems to fail at the if statements. Does this look right, or suggestions?

Code:
# Default to the mod_rewrite method, since it seems more efficient.
<IfModule rewrite_module>
    RewriteEngine On
    RewriteCond %{Request_URI} !\.(css|js|jpg|gif|png|tif|swf|flv|ico|cur)$ [NC]
    RewriteRule .* - [F]
</IfModule>

# If mod_rewrite is not loaded, fall back to mod_setenvif method.
<IfModule !rewrite_module>
    SetEnvIf Request_URI "\.css$" object_is_css=css
    SetEnvIf Request_URI "\.js$" object_is_js=js
    SetEnvIf Request_URI "\.jpg$" object_is_jpg=jpg
    SetEnvIf Request_URI "\.gif$" object_is_gif=gif
    SetEnvIf Request_URI "\.png$" object_is_png=png
    SetEnvIf Request_URI "\.tif$" object_is_tif=tif
    SetEnvIf Request_URI "\.swf$" object_is_swf=swf
    SetEnvIf Request_URI "\.flv$" object_is_flv=flv
    SetEnvIf Request_URI "\.ico$" object_is_ico=ico
    SetEnvIf Request_URI "\.cur$" object_is_cur=cur
    Order deny,allow
    Deny from all
    Allow from env=object_is_css
    Allow from env=object_is_js
    Allow from env=object_is_jpg
    Allow from env=object_is_gif
    Allow from env=object_is_png
    Allow from env=object_is_tif
    Allow from env=object_is_swf
    Allow from env=object_is_flv
    Allow from env=object_is_ico
    Allow from env=object_is_cur
</IfModule>
Reply With Quote
  #15  
Old 05-22-2010, 05:37 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,227
tested your code in local lsws, it's working.

but I think the 2nd part
<IfModule !rewrite_module>
really not necessary. it adds extra overhead.
mod_rewrite is a very basic module and it's hard to imagine apache without rewrite module existing in any hosting provider.
Reply With Quote
  #16  
Old 05-22-2010, 04:26 PM
Morpheus Morpheus is offline
New Member
 
Join Date: May 2010
Posts: 8
It seems that Lightspeed is processing all IFModule statments. If the first IFModule statement is true, then it should gracefully exit without running the second IFModule routine, but it doesn't. Is there a way to accomplish this?

Also how do you create a rewrite rule that will replace this:

Quote:
# ----------------------------------------------------------------------
# Purpose of file: block any web access to files stored under
# the downloads_upload directory
# ----------------------------------------------------------------------
Order deny,allow
Deny from all
Reply With Quote
  #17  
Old 05-23-2010, 02:28 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,227
I think need go through .htacess, since there may be other directives in the file.

A rewrite equivalent for "Deny from all":
Code:
RewriteEngine On
RewriteRule .* - [F]
Reply With Quote
  #18  
Old 05-23-2010, 05:45 AM
Morpheus Morpheus is offline
New Member
 
Join Date: May 2010
Posts: 8
Quote:
Originally Posted by NiteWave View Post
I think need go through .htacess, since there may be other directives in the file.

A rewrite equivalent for "Deny from all":
Code:
RewriteEngine On
RewriteRule .* - [F]

In the below example only, after the first IFModule statement is read it should exit before reading in the next IFModule statement but it doesn't. Is there a way to do this in the htaccess file?

Code:
<IfModule rewrite_module>
    RewriteEngine On
    RewriteCond %{Request_URI} !\.(css|js|jpg|gif|png|tif|swf|flv|ico|cur)$ [NC]
    RewriteRule .* - [F]
</IfModule>

<IfModule !rewrite_module>
RewriteEngine On
RewriteRule .* - [F]
</IfModule>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:27 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.