Forum Moderators: phranque

Message Too Old, No Replies

htaccess conditional on apache version

         

thing3b

7:08 am on Jan 7, 2008 (gmt 0)

10+ Year Member



The following code works in Apache 2 but not Apache 1:


<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>

How can I make this code only work in the .htaccess file if DirectorySlash option is available? (Version 2 of Apache)

coopster

7:01 pm on Jan 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why would you want to do this? Have you read the security warning?
[httpd.apache.org...]

thing3b

8:20 pm on Jan 7, 2008 (gmt 0)

10+ Year Member



I was quite aware of the security warning. It does start with "Consider a situation where mod_autoindex is active". Personally I think mod_autoindex itself is just asking for trouble and it is always turned off.

Do you know how to get DirectorySlash to be conditional on the Apache version?

thing3b

9:55 am on Jan 20, 2008 (gmt 0)

10+ Year Member



So I take it that no one has an idea?

phranque

10:36 am on Jan 20, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



<IfVersion >= 2.0.51>
# this happens only in versions greater or equal to 2.0.51.
DirectorySlash Off
</IfVersion>

thing3b

7:29 pm on Jan 20, 2008 (gmt 0)

10+ Year Member



Yeah, but the IfVersion thing is only available in versions 2.0.56 and above, so it is not much help to me.

phranque

2:05 am on Jan 21, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



my bad!
sorry i didn't notice that...

gergoe

3:33 am on Jan 21, 2008 (gmt 0)

10+ Year Member



What you want to achieve by turning this off? Possibly there's a way to emulate the turned off behavior with mod_rewrite?

mod_dir initiates subrequests for the resources stated in DirectoryIndex, so you could grab for example these requests in your htaccess, and do something else? At least that's what you might be able to do with the root directory, but in the case of subdirectories this might be even easier?

Just thinking loud, but if you explain your situation better, maybe someone can offer you an alternative way.