Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prohibit listing the files? 2

Status
Not open for further replies.

IPOz

Programmer
Jul 11, 2001
109
CN
Hi,friends,
When i used to visit our site,the apache will return the file list in that directory :(
How can i prohibit it ?


thanks in advance ! IPO_z@cmmail.com
Garbage in,Garbage out
 
Hi,

Just thought I would let you know an easier way to do it without having to place an index file in every directory,

just add the red part to the end of the DirectroyIndex..

DirectoryIndex index.html index.htm /404.html

You can change the 404.html to whatever you want and make sure that the file specified is in the root directory.. If none of the other files are present, this is called.

Hope this helps Wullie

 
wullie ,
it doesnot work .
....
DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php3 index.cgi /404.html
...
when i visit it always returns the file list :(

BTW,if put index.html into imonitor it works great :)


Thanks for all your answers ! IPO_z@cmmail.com
Garbage in,Garbage out
 
Surprising !
After put 404.html to / and restart apache,
still returned the file list
but
returned the 404.html !!!

what the difference between imonitor and test?
The imonitor holds the jsp files and i have built a symbol link on $(TOMCAT_HOME)/webapps as below:
$ln -s /var/ imonitor

BTW,
I added the following statement in httpd.conf
...
LoadModule webapp_module modules/mod_webapp.so
AddModule mod_webapp.c
WebAppConnection conn warp localhost:8008
WebAppDeploy imonitor conn /imonitor


Best Regards! IPO_z@cmmail.com
Garbage in,Garbage out
 
Um... everyone so far has been proposing workarounds instead of just getting to the source of the problem. Making it so a 404.html page shows up is a non-standard behavior, for sure. What you want is for Apache to output a 403 Forbidden page, which is done automatically, if you change your settings as I describe below.

Apache only lists directories if:

1. mod_autoindex is loaded. If you want to completely turn off this behaviour, just comment out:
#LoadModule autoindex_module libexec/mod_autoindex.so
and
#AddModule mod_autoindex.c

or... if you want this setting to be available, but turned off by default, then see point 2.

2. The <Directory /path> container for the location in question has &quot;Indexes&quot; listed among the Options, as in:

<Directory &quot;/usr/local/apache/htdocs&quot;>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

The above lists a fairly &quot;wide open&quot; setting, where indexes are available for any directory without an &quot;index.html&quot; file. To disallow directory browsing, simply do

<Directory &quot;/usr/local/apache/htdocs&quot;>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

(Note: you might want to take out MultiViews also, if you are really security-conscious, even though it doesn't directly deal with the same issue)

Now, we have configured the system by default to restrict directory viewing, but let's say we want a certain folder to allow browsing. Then we can add an .htaccess file in that directory which turns on the behavior, or we can just specify in httpd.conf:

<Directory &quot;/home/rick/public_html/mysharedfiles&quot;>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

By the way, do you want your own special icons in the Apache directory indexing? Just go to the <IfModule mod_autoindex.c> section of httpd.conf, and you will see where the lists of icons are defined. Just point to your own icons, and you have a customized directory listing ;-).
-------------------------------------------

&quot;Now, this might cause some discomfort...&quot;
(
 
Hey all,

I am having a similar problem. I DO have an index.html file in a particular directory, but instead of calling that file, I get a directory listing. I have made sure that the autoindex lines are present, and DirectoryIndex index.html is present (both globally and inside my <VirtualHost ...:443> section.

I have restarted my apachectl all the time.

I have tried the .htaccess to redirect to the index.html, and I have added a RedirectMatch in my httpd.conf for the offending directory. Both didn't help.

What more can I try? Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Einstein47
Check that the permissions are right on your index.html - anything other than you need 555 minimum really for straight html. ***************************************
Party on, dudes!
[cannon]
 
KarveR,

Yep, the file is rwxr-xr-x (or 755). I had already thought of that.

Could it be that we are using WebSphere 4.0.2? This index.html is in a Virtually hosted directory inside of WebSphere. Maybe that is what is confusing Apache?

I would post this in the WebSphere forum, but that place is zombie-ville (not dead, but really close to it). Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Hi mate,

What version of apache are you using??

The reason I ask is that I have a similar problem on one machine and no matter what I try I get the same results as you are getting..

I have tried everything and nothing seems to work..

Also, when you get the directory listing, what is the heading..

I am getting &quot;Index of /index.shtml&quot; and the directory listing is blank..

If I type in domain.co.uk/index.shtml then it works..

I am cracking up here!! Never had this problem on any other machine..

Hope this helps Wullie

 
I'm using IBM HTTP Server 1.3.19.1 (based on Apache 1.3.19.2)

I'm not sure that I can move my directories. I really think this is a WebSphere issue not Apache. I can't understand why one of your servers is acting crazy with this directory issue. Are they all the same type, same OS, same version?

I can't seem to get the .htaccess files to be recognized at all with WebSphere in the mix. I think that WebSphere is doing something evil, but I don't know exactly what.
Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top