mod_rewrite to hide files..?

Extrarius

Verified User
Joined
Nov 7, 2005
Messages
8
I'm trying to make it so that if you go to
Code:
http://site.com/folder/anything
it will redirect you to
Code:
http://site.com/folder/
and show the index file

I can get it to work, but I have to include the directory index as an exception because apparently when apache tries to return the directory index, it runs it through the rules also.

This means that you can type:
Code:
http://site.com/folder/index
and it won't redirect you (if it did, it would make an infinite loop since the redirect is a R=permanent external redirect). Is there a way to make the rule not run for the internal redirect done automatically by the DirectoryIndex directive? I want the person to get the index only by going to the directory, not by typing in the file name (it should redirect to the directory if they type the file name).

Also, because I have a FileMatch that matches all files starting with a dot and denies all, if you type one of those file names you'll get a 403 Forbidden page instead of a proper redirect. Is there a way to make it always redirect you even for files denied via FileMatch, or is the only way to make it allow access to those files?
 
Back
Top