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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a directory in the browser 1

Status
Not open for further replies.

abiale

Vendor
Aug 9, 2002
20
PL
I`d like to ask you for help.

My question is: how to disable users from displaying the contents of a directory from a browser if they put adress/anydirectory1/ ?

I`d like to redirect them to the login page or to display a error message ("Acces forbidden")

I`d would be grateful for any help.

Thanks,

Arthur
 
All directories should have an index.html in them to prevent this. This index page could be blank or contain a message saying they have no cotton pickin' business being there and a link back to where they should be.
 
You can do it. You must to edit httpd.conf and delete the word &quot;Indexes&quot; on &quot;<Directory /path/to_your/pages>&quot; line &quot;Options&quot;. so it must NOT looks like:

<Directory /path/to_your/pages>
Options Indexes
AllowOverride none
Order Allow, Deny
Allow from All
</Directory>

Take a look on:


Cheers.
 
Hi,

I am trying to to get my webserver to display an smb mount file list from a windows server in apache and was wondering a few things about security. Is there a way to set up apache to display a directory listing but confine them to that directory and below and not have them be able to navigate up the tree ? Where is the best place on the file system to secure the mount point ?

So far all I have done is add an alias entry to my httpd.conf file to get the directory listing to appear.

Does anyone have any thoughts about this ?

Thanks

Kevin
 
Well,

If you change httpd.conf as Chacalinc said earlier:

Code:
<Directory /path/to_your/pages>
Options -Indexes 
AllowOverride Indexes
Order Allow, Deny
Allow from All
</Directory>

Make sure the Indexes has a '-' before it!

Then in the directory that you want people to have a directory listing for, create a .htaccess file with:

Code:
Options Indexes

This will allow you to have a single folder to have a directory listing. IIRC the parent directory is still listed as an option; if you click it though you will get an access forbidden error as the parent doesn't have Indexes enabled.

D
 
Danomac,

Thanks for the info. I tried what you said and got an error. The error log says &quot; Options not allowed here &quot;.

Any ideas ?

Thanks
 
Make sure AllowOverride isn't disabled elsewhere in httpd.conf.

I had that problem too. :)

D
 
Or to clarify, look for 'AllowOverride None' in your httpd.conf. It's set to None by default.

D
 
Danomac,

Actually what I did was this to make things work:

first removing Indexes from this line in the config file (Default for httpd.conf)

Options Indexes FollowSymLinks

to

Options FollowSymLinks

then I had to modify my directory directives as follows:

Alias /pricepages/ &quot;/var/
<Directory &quot;/var/ Options MultiViews
AllowOverride Options
Order allow,deny
Allow from all
</Directory>

After that the .htaccess file entry you mentioned worked.

Now two things, first off what is the purpose of using the - ? Does it simply reverse a pre-defined (or system default) entry in the script?

Secondly, is there a simply way to secure a directory within that document root with html files to prompt a user for a username and password ? (I have one directory where I want everyone to have access to and one that I want protected in that document root.) I've read a little bit about it but would appreciate some clarity.

Kevin
 
JVKAdmin,

Using the '-' disables indicated option. Hence, -Indexes disables Indexes.

To use that in an example, say that you wanted directory browsing in ALL folders except one. You would change your AllowOverride to Indexes, and set the .htaccess file in the single folder you want to protect to -Indexes.

You can do an authentication through Apache to a specific folder. Remember though that the username and password are sent in cleartext. If it's mission critical you may consider running a secure web site so the user/pass info is encrypted.

I don't know the exact steps to setup a authenticated folder off the top of my head, I'll post more info on that later.

D
 
Danomac,

Thanks for the link. I believe we are using Apache 1.3 however.

Kevin
 
As an experiment, I wanted to disable directory viewing. To do so, I deleted "Indexes" from the "Options" line and all was well.

To go back to the original config, whereby I would get a directory listing, I restored the following code:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "C:/locserv">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Instead of the directory listing, however, I am now getting a "Forbidden" error page from Apache 1.3.31. (On MS XP Pro SvcPk 2).

Is there some kind of locking that takes place that I need to undo? I was under the impression that the initial:

<Directory />
...
</Directory>

Took care of all that.

Thanks in advance for your help.
 
Never mind.

Lesson learned... when one gets an error message, one should check the error log. Once I did, the error was obvioius and had nothing to do with the directories setup.

Sorry about that but perhaps someone will learn from my stupidity.

Lexis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top