How to apply htaccess to a folder but not subfolders

wanalex

Distinguished
Jun 15, 2010
3
0
18,510
Hi,

I'm doing a very simple website for local users on my network.

basicaly the links on the website point to a directory where files are listed automatically.

The structure is simple:

WWW/movies/subfolders
WWW/music/subfolders
www/games/subfolders

I put an htaccess in the root of movies music and games:

Options +Indexes

IndexOptions FancyIndexing
IndexOptions FoldersFirst
IndexOptions SuppressDescription
IndexOptions NameWidth=80
IndexOptions SuppressLastModified
IndexOptions SuppressSize
IndexIgnore ..

htaccess affects the folder but the subfolders as well...

Is it possible to have the rule "IndexIgnore .." apply for the folder only but not to the subfolders?

Any help would be appreciated. Thanks
 

Ijack

Distinguished
You need .htaccess files in the subdirectories that override the one in the root. Otherwise, as you have found, what you specify in .htaccess also applies to all subdirectories. In those lower-level .htaccess files you would use the directive:

Options -Indexes

Actually, if the web server is under your control, it is more efficient to set these configurations in the main .config file rather than using .htaccess.
 

wanalex

Distinguished
Jun 15, 2010
3
0
18,510
yeah I could, put a htaccess in each folder, but the point of this easy server is to put files in a folder and let apache do the work. if i put 200 folders in, I really dont want to put a htaccess in each and then check that everything is working...

I don't know if you could understand from my previous post why i would remove parent directory from folder only.

In fact if a user is in /movies he can browse the movies, but I dont want up to go up to the root folder or have any error message.

when you use the automatic listing from apache, in the root directory, the parent directory link disappear :)

I'd like to give this property for my folder movies and any other folder i'd put the htaccess into.

another thrick would be to use the command rewrite to relink the parent directory to the directory itself so a click on the parent directory in folder would send you back to folder...
my knowledge in this is very limited and i cant do it yet...

Any trick that could achieve what i'd like to do it very welcome.
Thanks
 

Ijack

Distinguished
Well, why not create an "index.html" file in the root directory that lists "movies", "music", and "games", then put .htaccess files in those 3 directories (or however many top-level ones you have). When you do "Parent Directory" from one of them it will access the "index.html" file from the root. That way you don't need .htaccess files in all the subfolders, just the top-level ones.

Or do you not want people to be able to browse to "movies" from "music"?
 

wanalex

Distinguished
Jun 15, 2010
3
0
18,510
I do have an HTML file that list movies, music and game. They point to a movies.html, ...
The problem was that the listing was an object in movies page. if click on parents directory, the index.html appears as an object in movies.html :)

Anyway I've solved the problem in another very tricky way :)
I put a header.html in the htaccess, and ignoreindex ..
Then in the header. html I created a button back that brings you to the previous page. It works perfect :)

Thanks for your time, and when I see your post, i'm happy that I had the same way of organizing thing as you :)

Cheers