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

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > [Resolved] htaccess file directives in subdirectories

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2010, 12:42 PM
Park Park is offline
New Member
 
Join Date: Mar 2010
Posts: 2
Default [Resolved] htaccess file directives in subdirectories

I have the following htaccess file configured for one of my user's websites in /home/username/public_html/store:
Options -Indexes
<Files ~ "\.php$">
order allow,deny
deny from all
</Files>

So this will basically block php files from being accessed in this directory and all subdirectories when I visit mydomain.com/store (and any subdirectories within it)

Now I have a subdirectory within /store called /store/myimages and need to access php files in here so I placed the following .htaccess file within /home/username/public_html/store/myimages:
Options +Indexes
<Files ~ "\.php$">
order allow,deny
allow from all
</Files>
allow from all

What should happen is that the htaccess in this subdirectory should override the file directive in the directory above it. However, this does not work. I tested this exact same setup in Apache and it does work, but not on Litespeed. Any suggestions?

Last edited by NiteWave; 05-11-2010 at 06:06 PM..
Reply With Quote
  #2  
Old 03-05-2010, 03:59 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,218
a suggestion: using RewriteRule instead of Files,order,allow/deny from

in /home/username/public_html/store/.htaccess
Code:
Options -Indexes
RewriteEngine On
RewriteRule \.php$ - [F]
in /home/username/public_html/store/myimages/.htaccess
Code:
Options +Indexes
RewriteEngine On
RewriteRule \.php$ -
Reply With Quote
  #3  
Old 03-05-2010, 01:22 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
Or, use

php_value engine off

and

php_value engine on

in .htaccess to control PHP support.
Reply With Quote
  #4  
Old 05-06-2010, 08:30 PM
aww aww is offline
Senior Member
 
Join Date: May 2007
Posts: 237
Wait, litespeed doesn't support "deny from all" ?

Or it doesn't support Files/FilesMatch ?

(or both?)
Reply With Quote
  #5  
Old 05-06-2010, 11:18 PM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,218
yes, lsws suport these directives.

if you experience "not working", please refer
http://www.litespeedtech.com/docs/we...#allowOverride
to check AllowOverride setting for "Limit", "FileInfo" etc.
Reply With Quote
  #6  
Old 05-09-2010, 09:36 PM
aww aww is offline
Senior Member
 
Join Date: May 2007
Posts: 237
Well I have all those override options checked.
And this simply doesn't do anything
Code:
<Files config.php>
  order allow,deny
  deny from all
</Files>
config.php can still be requested via http

possibly a parent rule interfering?
if I remember correctly litespeed has an issue with inherit

this works
Code:
RewriteCond &#37;{SCRIPT_FILENAME} config\.php$ [NC] 
RewriteRule .* - [F]
however it bothers me there is not full apache compatibility via files/deny from all

Last edited by aww; 05-09-2010 at 09:53 PM..
Reply With Quote
  #7  
Old 05-09-2010, 11:12 PM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,218
I did more tests on 4.0.14 standard, using exactly same lines as yours:
Code:
<Files config.php>
  order allow,deny
  deny from all
</Files>
in vhost level when AllowOverride any one of Limit/Auth/FileInfo/Indexes/Options
is checked, "deny from all" will take effect, return
403 Forbidden
Access to this resource on the server is denied!

however, if "None" is checked, or no check at all, "deny from all" won't take effect, the result is what you experienced.

I'll test on apache soon.
Reply With Quote
  #8  
Old 05-10-2010, 12:18 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,218
appache 2.2.14

when AllowOverride Options/FileInfo/AuthConfig/Indexes (one of them)
return
Quote:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
...
when AllowOverride All/Limit (one of them)
return
Quote:
Forbidden
You don't have permission to access /test.html on this server.
when AllowOverride None ,return normal result. -- "deny from all" is ignored.

summary for apache, when virtual host level AllowOverride is set to All/Limit, "deny from all" take effect, will return "403 Forbidden" -- as expected. when AllowOverride Limit is not explicitly set but other AllowOverride option is set, the return result looks undefined -- "500 Internal Server Error" in my test.

here's apache's docs:
http://httpd.apache.org/docs/2.0/mod...#allowoverride
"When this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem."
"Default: AllowOverride All"
Reply With Quote
  #9  
Old 05-10-2010, 01:17 AM
aww aww is offline
Senior Member
 
Join Date: May 2007
Posts: 237
Sorry for not being clear, I am not checking "none" but all the others are checked.

I will try this on a clean vhost, there must be something else interfering, hard to track down.
Reply With Quote
  #10  
Old 05-10-2010, 01:46 AM
aww aww is offline
Senior Member
 
Join Date: May 2007
Posts: 237
Okay I found the problem and it's likely my fault.

I had another rule with Order deny,allow (instead of allow,deny) AFTER this config.php rule.

So apparently the effect is cumulative and litespeed goes through ALL the rules before making a decision, instead of failing the file right away.

Not sure if that is how apache behaves (easyapache no longer builds for me so I can't test)

Does apache die immediately or wait to see what other rules do?

try putting this AFTER the config.php rule

Code:
<Files *>
order deny,allow 
deny from 4.4.4.4
</Files>
it works properly if I move it BEFORE the config.php

I guess I am used to mod-rewrite which will die immediately when told to do so.

ps. just out of curiosity does lsws support SetEnvIf and allow from env=

Last edited by aww; 05-10-2010 at 01:49 AM..
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 08:42 PM.



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