Helpful Information
 
 
Category: Apache Development
DirectoryIndex

Hi,

I am trying to change the defalt index file for a particular directory by using DirectoryIndex in htaccess. I con't seem to get it to work. My htaccess file looks like this:

<FilesMatch ".inc.php$">
require valid-user
AuthUserFile /dir/.htpasswd
AuthName ISE-Forums
AuthType Basic
</FilesMatch>

DirectoryIndex wwwthreads.php

But I get an error that looks like this:

[Tue Feb 13 08:47:31 2001] [alert] [client 64.230.176.170] /dir/.htaccess: DirectoryIndex not allowed here


It seems kosher how I implemented DirectoryIndex, but something obviously is not.

Any ideas?

Thanks.

First, AuthUserFile /dir/.htpasswd, the /dir must be full server path, not relative URL path.

Second, <FilesMatch ".inc.php$">, you need to escape the dot.

Third, placing .htpasswd in the same dir of your protected files is absolutely fine, but you need to make sure it's not directly accessible from browser. If you try to access http://www.yourdomain.com/dir/.htpasswd after authenticated and get [403] error, then you're fine.

Thanks for the reply.




Originally posted by freebsd
First, AuthUserFile /dir/.htpasswd, the /dir must be full server path, not relative URL path.


It actually is. I removed the full path in the example I posted to forum for security reasons.



Second, <FilesMatch ".inc.php$">, you need to escape the dot.


This is working fine as I have it set up now. The problem I am having is with the DirectoryIndex wwwthreads.phpwhich returns an error. Perhaps the problem is related to how I have the FilesMatch section set up.

How would I escape the dots?

Any other ideas on why DirectoryIndex wwwthreads.php is not working?

Thanks!

Michael

>> Any other ideas on why DirectoryIndex wwwthreads.php is not working?

Because you have told Apache not to allow Indexes to be overridden by .htacess.

Check your httpd.conf for the <Directory> block of /path/to/dir and add Indexes to the AllowOverride line. Check here for more info -> http://httpd.apache.org/docs/mod/core.html#allowoverride

>> How would I escape the dots?

\ before the dot.

Thanks! That was the problem!

Michael










privacy (GDPR)