LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-20-2001, 10:11 PM   #1
chuck77
Member
 
Registered: Nov 2001
Location: singapore
Posts: 120

Rep: Reputation: 15
how to prevent directory listing in apache ?


http://swamp.chl.chalmers.se/apache/dist/

For yr reference, if u click the url above, u see the index of the
files in the directory. How do i prevent this in apache..??
where it will deny access to that directory directly...when we type the url. How do u redirect it to the root page ...?? eg below url.

http://swamp.chl.chalmers.se
 
Old 12-20-2001, 10:36 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
the quickest way is you could use the Alias command or you could possibly use the Redirect command.

examples:
Code:
Alias /apache/dist "/www/home" and
Redirect [status] oldURLprefix newURLprefix
or you could even just have a template page setup as a regular html page to use for anypage named index.html or something that has some dynamic html or script to redirect users to the default homepage instantly or something like that.

Last edited by trickykid; 12-20-2001 at 10:40 PM.
 
Old 12-20-2001, 10:53 PM   #3
chuck77
Member
 
Registered: Nov 2001
Location: singapore
Posts: 120

Original Poster
Rep: Reputation: 15
is there any other way out other than the Alias and Redirect command. Is there any way to control the directory ??

Pls advise..
 
Old 12-20-2001, 11:26 PM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Are you wanting some access to the listing or no access to be seen from the web ??

Maybe someone else knows of another way.. if you don't want any access, best bet is probably the redirect command..

there are other methods like using the mod_block.c or a another URL rewriter is the mod_uri_remap.c instead of the mod_rewrite in which i forgot about in my previous post..

so your best options are basically the

Redirect, Alias and Rewrite commands.. you can find more info most likely at www.apache.org
 
Old 12-21-2001, 12:58 AM   #5
chuck77
Member
 
Registered: Nov 2001
Location: singapore
Posts: 120

Original Poster
Rep: Reputation: 15
let say, i have many levels of sub-directories..example 20 level.

Do i have to type in the code for each and every sub directories redirection ??? This is a tedious process. any other way round ?

Thanks for watever info u gave...!
 
Old 12-21-2001, 01:44 AM   #6
chuck77
Member
 
Registered: Nov 2001
Location: singapore
Posts: 120

Original Poster
Rep: Reputation: 15
for all who need this..

I found from one website...

from the main directory in the server, change the mode to the directory where u load all the html files for public. This will prevent the directory listing..providing u hav access to server.

#chmod 700 /directory
 
Old 12-21-2001, 01:45 AM   #7
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
cool.. a quick easy way with permission settings..

Last edited by trickykid; 12-21-2001 at 01:46 AM.
 
Old 12-21-2001, 04:27 AM   #8
chuck77
Member
 
Registered: Nov 2001
Location: singapore
Posts: 120

Original Poster
Rep: Reputation: 15
for all

My previous suggestion is a fault...cos no one is able to access the webpage.

You may check the * IndexIgnore * option in httpd.conf.
Use wildcard to prevent listing of the directory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Directory Listing Of NFS Mount, cannot view directory list via apache luqmana Linux - Networking 2 12-19-2005 07:03 AM
apache directory listing doralsoral Linux - Software 2 06-15-2005 08:37 AM
apache - directory listing thejackal13 Linux - Software 1 01-05-2005 11:31 AM
Directory Listing with apache aroop Linux - Networking 2 06-02-2004 03:50 AM
apache 2 directory listing jwatco2001 Linux - Software 5 06-07-2003 07:29 PM


All times are GMT -5. The time now is 09:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration