Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

First time writing an .htaccess, so...

I try to allow indexing of a dir and later one adding a password for the specific dir. I herefor am writing an .htaccess file.

The server I'm working on denies indexing of dirs (I think) yet not the use of .htaccess files in itself. I make that statement for it does not return an internal error when adding the following lines in my htaccess file in the dir I would like to allow indexing for:

[code]<Files index.html>
Order allow,deny
Allow from all
</Files>[/code]

I do get an internal error when I use the following:

[code]<Files index.html>
Order allow,deny
Allow from all
</Files>

<Directory>
Order allow,deny
Deny from all
</Directory>[/code]

I used the above for they are very simple statements and I am merely checking whether the .htaccess file works.

I presume that this has something to do with a deny in some config file on the server. I checked the apache2.conf and modifying that one did not seem to do much. Maybe I modified it incorrectly, however... I also think it might have something to do with the 000-default file (/etc/apache2/sites-enabled/) for their it is stated the following: [code] ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride Limit
    Order allow,deny
    allow from all
</Directory>[/code]

Which I presume must become a +Indexes. But the file 000-default is a symbolic link and I don't know where it links to and where the file can be found. Or should I not touch this one and add a new file linking to the dir...

share|improve this question
    
You don't need those [Code] pseudo-tags in your question, If I were you I'd edit them out for clarity. –  RedGrittyBrick Dec 14 '10 at 15:02
add comment

1 Answer

According to the documentation: <Directory> cannot be used in an htaccess context.

What happens when you place Options Indexes or DirectoryIndex index.html in your .htaccess?


The use of .htaccess files in directories (and what they are allowed to contain) has to be configured in the main apache2.conf configuration file (or in a config file it includes) as described in the documentation for AllowOverride

My Apache configuration file has

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

The AllowOverride None applies to all directories that are a subdirectory of /. Later there should be this

<Directory /var/www>
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

Which reinforces that rule for the main Document Root and all it's subdirectories.


The filename .htaccess is a default but can be changed using the AccessFilename directive in apache2.conf, so I would check that this directive is NOT present.


When you edit apache2.conf you should ask the running Apache service to reload it's configuration. One way to do this is

apache2ctl configtest

If Apache says your config is OK, ask it to load it without stopping

apache2ctl graceful
share|improve this answer
    
I still get (for both) a 500 internal error. Just to make sure: I have the htaccess in the dir I would like to allow indexing... –  dakke Dec 14 '10 at 15:21
1  
For any "500 - internal error" response there will be some informative description of the problem in the errors_log file (which might be configured with a different name or a vhost specific name) - Can you see what the error log says? Also, can you update your question with the full contents of .htaccess (just XXX over any sensitive data values)? –  RedGrittyBrick Dec 14 '10 at 17:06
    
Thanks for the reply, learning a lot here. The error that is logged: "[Tue Dec 14 17:29:59 2010] [alert] [client xxx] /var/www/development/.htaccess: DirectoryIndex not allowed here".Which full access of the .htaccess do you mean. For the .htaccess in the dir I would like to index, is exactly what you wrote in post before namely "DirectoryIndex index.html". –  dakke Dec 14 '10 at 17:12
    
See amended answer –  RedGrittyBrick Dec 14 '10 at 17:22
    
Thanks, for that I added in that apache2.conf the following: <Directory "/home/html/development/"> AllowOverride All </Directory> The following does not work either (the dir as referred in error log): <Directory "/var/www/development/"> AllowOverride All </Directory> Yet, that does not do much, still get the error. Same error log. –  dakke Dec 14 '10 at 17:33
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.