Forum Moderators: phranque

Message Too Old, No Replies

Options –Indexes not working in <VirtualHost >

         

milanmk

9:35 am on Dec 18, 2006 (gmt 0)

10+ Year Member



I would like to disable directory listing for a particular domain from httpd.conf. But the following settings don't work ONLY for "Options –Indexes", rest all is working fine. Any suggestions?


<VirtualHost IP>
ServerAlias domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /home/domain/public_html
User domain
Group domain
ServerName www.domain.com
CustomLog /usr/local/apache/domlogs/domain.com combined
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/

Options -Indexes +FollowSymLinks

RewriteEngine on
RewriteCond %{HTTP_HOST}!^domain\.com [NC]
RewriteRule ^/(.*) [domain.com...] [R=301,L]

AddType application/x-httpd-php .php .htm
</VirtualHost>

coopster

4:50 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Did you restart Apache? And refresh your browser? Actually, clear the browser cache ...

milanmk

5:23 pm on Dec 18, 2006 (gmt 0)

10+ Year Member



Yes, without fail.

Milan

coopster

5:32 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you certain you don't have any per-directory override files (.htaccess) in the path somewhere that is overriding your Options [httpd.apache.org] setting?

milanmk

6:38 pm on Dec 18, 2006 (gmt 0)

10+ Year Member



Well there is no .htaccess file in public_html or any sub directories.

I did a test and found that when I add "Options -Indexes" in .htaccess then its working perfectly fine, I mean it disables directory listing. Now this is really strange thing happening here! The same thing is not working in httpd.conf and its working fine in .htaccess file.

Do you think is there any configuration fault in Apache?

Milan

coopster

8:55 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I know the question seems simple, but I have to ask ... are you certain you are maintaining the relative <VirtualHost> container for that domain/ip and not working in a different <VirtualHost> container?

If it is working in the .htaccess file I cannot see any reason why it would not be working in the httpd.conf upon restart.

milanmk

5:00 am on Dec 19, 2006 (gmt 0)

10+ Year Member



Certainly yes, because there is only one <VirtualHost> in my httpd.conf right now.

Did another test of adding <Directory> in httpd.conf and that too is working fine.

<Directory /home/domain/public_html>
Options -Indexes
</Directory>

This is really getting out of my head! By the way my Apache version is 1.3.37 if that could give you some version specific clues.

Milan

coopster

12:04 am on Dec 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm assuming that is your entire <VirtualHost> container posted in the first message. Try commenting out your rewrite directives there and reboot. See if your Options directive works then.

milanmk

5:36 am on Dec 21, 2006 (gmt 0)

10+ Year Member



Sorry for replying late.

I even tried that and in fact tried all the other possibilities I can think of, with no success.

Milan

jdMorgan

2:39 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If there are multiple Options directives in your config file, then beware of the following subtlety:

Normally, if multiple Options could apply to a directory, then the most specific one is taken complete; the options are not merged. However if all the options on the Options directive are preceded by a + or - symbol, the options are merged. Any options preceded by a + are added to the options currently in force, and any options preceded by a - are removed from the options currently in force.

However, if another Options +/- directive is more-specifically scoped than the one you are trying to override Indexes with, then the override won't work until you scope it more specifically. This might explain why you are finding it necessary to put the Options directive into a <Directory> container or into .htaccess, where the scope is more specific.

At least, it's possible. This problem makes my head hurt...

Jim

wilderness

4:45 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This problem makes my head hurt...

Hey Jim,
Perhaps you been behind the computer so long that you haven't visited the newer pharmacies?
They sell aspirin and yes, even Tylenol ;)

Don

milanmk

6:55 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



At least, it's possible.

I was waiting for your feedback Jim, thank you for making me believe it CAN happen.

The only reason I was try hard to put it into <VirtualHost> was to make my code simple and error free. But now I think I have to live without it!

Milan