Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
So I have my Apache server setup on tiger server almost exactly how I want it. One thing is still messing with me though, that is directory browsing.

I want to enable directory browsing. Shouldn't it be as simple as placing a .htaccess file on the root of the server? (that is /Library/WebServer/Documents)

This is the contents of my .htaccess
Code:
Options +Indexes

am I missing something? :confused:


Thanks,


Edit:
Also when I am browsing to the server and I browse to a directory without an index file I am getting a 403 Forbidden error... Which I assume is because I don't have directory browsing turned on...
 
Code:
## AccessFileName: The name of the file to look for in each directory
## for access control information.
##
AccessFileName .htaccess

I never explicitly enabled it, but that is what the lines look like.
 
in httpd.conf there sould be something that looks like
Code:
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
#^ this is the line important for .htaccess files (this is what I meant originally)
Order allow, deny
Allow from all
</Directory>
With it setup like this, you simply need a .htaccess file in every directory you don't want users to be able to see.

You can do a few other things to disable it for every directory though.
In that code you can remove the word Indexes, and/or comment out mod_autoindex add-on.


Lastly remember to restart the apache server after making changes to the httpd.conf file.
 
Code:
<Directory "/Library/WebServer/Documents">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	#Order allow, deny
	Allow from all
</Directory>

I had to comment out the "Order allow, deny" line because it was causing the httpd to not start back up.
Umm, and it still isn't working at all for me.

this is the original part of the conf file,
Code:
<Directory />
	Options FollowSymLinks
	AllowOverride None
</Directory>

Ive tried variants of that like so:
Code:
<Directory />
	Options Indexes FollowSymLinks
	AllowOverride All
</Directory>

This really baffles me.

Thank you for your help! :)


:apple:
 
The first part you had looked good except one small part, the one you had to comment out.
Code:
<Directory "/Library/WebServer/Documents">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  [B]Order deny, allow[/B]
  Allow from all
</Directory>
Since you are doing just the allow line you need to have the order statement say deny then allow. Give it a try, and remember to restart Apache of course.
 
hmmm, I am getting the same thing as before, when I comment out that same line it starts back up.

I just figured out the problem with the conf file,

by removing the space,
Code:
Order deny,allow

Apache is starting back up.


This is my section now,
Code:
<Directory "/Library/WebServer/Documents">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order deny,allow
  Allow from all
</Directory>

But I am still having the same issue as before not being able to browse the directories.
:eek:


Thank you both again for your help, it's really appreciated!

:apple:
 
You know I stared at that space and wondered about it for a moment.

Just to get some more info, are you using Tiger's pre-installed Apache web server (or MAMP)? Also, can you view other files you place in the web directory? And where are you storing the files (/Library/WebServer/Documents or /username/Sites)? Have you tried placing a .htaccess file inside a folder in the web folder to see if you can turn on indexes inside a specific folder?

Another thing, I can't remember if it was this way on Tiger, but at least on Leopard in /public/etc/apache2/users/ I have a username.conf file that sets these directory options for my Sites folder in my home directory. I'm pretty sure the exact folder location was different for Tiger, but it may still exist somewhere. Having another file override these changes would make perfect sense.
 
This is the pre-installed apache server (running both MySQL and PHP now for what it's worth, but there is almost no way either of those could cause the problem).

I can visit the files I access directly, but if there is no index file in a directory and I try go there to browse the files in that directory I get a 403. If I try to visit a file that doesn't exist I get a 404 (like expected).

the files are in /Library/WebServer/Documents

the .htaccess file has been in the Documents directory this whole time. I tried to delete it and try again to see if that made a difference but it didn't. I re-added the file to both the Documents folder, and the subfolder I am trying to access. still nothing.


Another thing, I can't remember if it was this way on Tiger, but at least on Leopard in /public/etc/apache2/users/ I have a username.conf file that sets these directory options for my Sites folder in my home directory. I'm pretty sure the exact folder location was different for Tiger, but it may still exist somewhere. Having another file override these changes would make perfect sense.


I took a look for that file, and didn't see anything.
I'll search more tomorrow, but it is getting late.

Thank you for your help!
:)
 
the .htaccess file has been in the Documents directory this whole time.

Ah, you've been editing the .htaccess file! You need to be editing the httpd.conf file. That's where you will need to allow overrides, because if it's not there all .htaccess files will be ignored.
 
Ah, you've been editing the .htaccess file! You need to be editing the httpd.conf file. That's where you will need to allow overrides, because if it's not there all .htaccess files will be ignored.

No, I have been editing the conf file, I as just saying the .htaccess file was still present (with that one line) the whole time.

do you have mod_autoindex enabled in httpd.conf?
yes, mod_autoindex is enabled

if it would help I could upload the conf file. I am getting a bit concerned.
 
I found some documentation for the Apache on Tiger. The path to the user-specific conf file is located at /etc/httpd/users/ rather than what I gave before. Though, it looks like you're accessing pages from the root rather than from your user directory, so this point is likely moot.

I'm pretty much out of ideas though, it should be working. The only other ideas I can think of at the moment is that there's multiple httpd.conf files being read in at startup and are conflicting. Have you possibly ever installed MAMP or the like? We can search out these possible additional files. Spotlight doesn't look deep enough so we'll use Terminal. From there enter the following command.

Code:
sudo find / -name 'httpd*.conf' -print
This can take up to a few minutes so be patient. It'll print out the path to each file it finds. Though, just because it finds one doesn't mean it's interfering with your setup. Just some place to start.

Edit: found a easier way to find files on the system without using Terminal.
Oops, I think this only works in Leopard.

  1. From Finder do a crtl+F to switch to find mode.
  2. On the menu that say "Kind" choose Other.
  3. This brings up a window, scroll down to "System" and select it
  4. This will now search out system files as well.
  5. Make sure in the next drop down over it's set to "include" rather than "not include"
  6. Then our search becomes 'httpd .conf" The space is intentional.
Source: http://www.macworld.com/article/60711/2007/10/spotsyssearch.html
 
This was a clean install of tiger server so I know MAMP has never been installed.

I ran the search and interestingly enough I found these two conf file (in addition to others)

/opt/apache2/conf/httpd.conf
/private/etc/httpd/httpd.conf

opened up the apache2 httpd conf file, and saw it showed the documents root as "/opt/apache2/htdocs"

I also edited the <Directory> part again thinking that would fix the problem. Restarted the server, and still causing the same problem.

The autoindex module is also installed on this file as well.


--

I also too a look for the users directory, and It is not in the httpd (neither etc nor apache2)
 
Hmm, quite odd. My last piece of advice is to install MAMP and change the httpd.conf it comes with :D I really like MAMP, though you shouldn't have to install it just because of a simple issue like this. It's probably something small we're overlooking too. You can post your httpd.conf file if you want. Someone here may spot something out of place, but just make sure there's nothing in the file that's sensitive.
 
renamed it with a txt extension for upload purposes...
this is the file located in /etc/httpd/

Thanks

:)
 

Attachments

  • httpd.conf.txt
    32.5 KB · Views: 234
I'll just give some feedback based on comparing your file to Leopard's default one, which I've never used. One section yours doesn't seem to have is,
Code:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
This sets the default behavior. I don't know if it's necessary or not. Your current <Directory "/Library/WebServer/Documents"> section looks fine and should come after the default section from above.

I did a quick test on my Leopard machine and turned on Web Sharing and threw a folder with some files an no index file in and went to access it through localhost and it showed an indexed list of the files. That was without making any modifications to the httpd.conf file. Though Leopard's httpd.conf file maybe be slightly different, but they look really close. My two relevant sections look like,
Code:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
 
hmmmm, still not working.

I redid all the lines of the <directory /> part too so they all allowed. That didn't open anything up either.

I appreciate the help but honestly it isn't even worth it any more, it's not that big of a deal.

If I find I need it in the future, I'll just install MAMP.


Thanks again!

:)



:apple:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.