[Resolved] DirectoryMatch and Directory causes all 404s to become 403s

aww

Well-Known Member
#1
The use of DirectoryMatch or Directory, ie.

Code:
<DirectoryMatch "\.(svn|git)">
   Order allow,deny
   Deny from all
</DirectoryMatch>
or
Code:
<Directory ~ "\.(svn|git)">
   Order allow,deny
   Deny from all
</Directory>
Causes any 404 to instead become a 403

ie. http://www.litespeedtech.com/ignore404fdgkdfgl1232365346.txt

should properly produce a 404

adding any directorymatch rule causes it to become 403, even if it's not affected by the rule
 
Last edited by a moderator:

mistwang

LiteSpeed Staff
#2
How was <Directory ...> directives are added?
If you add those via Apache Style configuration in LSWS web console, it wont work properly, you should use LSWS native Context configuration instead.
 

aww

Well-Known Member
#3
added via .htaccess

If litespeed doesn't support it, perhaps it could just ignore them so it doesn't break 404 errors.

The rules need to be left there for apache backward compatibility.
 

NiteWave

Administrator
#4
Hi,

I did tests on Apache 2, if in .htaccess there is
Code:
<DirectoryMatch "\.(svn|git)">
   Order allow,deny
   Deny from all
</DirectoryMatch>
normal access to a file will return "500 Internal Server Error". without "<DirectoryMatch" directive, will be "200 OK".
and there is an entry in error_log:
Code:
[Tue May 11 04:42:33 2010] [alert] [client x.x.x.x] /usr/local/apache/htdocs/.htaccess: <DirectoryMatch not allowed here
in apache doc:
http://httpd.apache.org/docs/2.0/mod/core.html#directory
Code:
<Directory> Directive
Context:	server config, virtual host
<DirectoryMatch> Directive
Context:	server config, virtual host
I was confused with it too. Thanks for raising the issue to get it clear.
 
Last edited:

aww

Well-Known Member
#5
Wow - that advice is given out all over the web and I guess everyone just repeats it without checking if it really can be used in .htaccess or not. Weird.
 
Top