I have a directory on my webserver. It does not have an index page. so when u access the directory via a web browser it lists the files in it. Now i want to create a htaccess file that can block the directory listing so that when you access it via the web browser, the files in the directory would not be listed but would be able to access the files by appending the name of the file you wish to access to the url making it a full part to the file. Also the htaccess file should be able to restrict access from all but files with a particular extention. Thanks.
+2
A:
You can turn off the file listing for a particular directory in the directory's .htaccess with
Options -Indexes
OR
You could just put an empty index.html file in the directory you want to protect.
Lenni
2009-05-07 22:26:52
+7
A:
Options -Indexes
Order allow,deny
Deny from all
<Files "*.gif">
Allow from all
Deny from none
</Files>
Adam Backstrom
2009-05-07 22:28:05
thanks for the response. And if i want to include multple viewable files, can i seperate them with |
War Coder
2009-05-07 22:46:05
Right, with regex: <Files ~ "\.(gif|jpe?g|png)$">. That example is directly from the Apache docs: http://httpd.apache.org/docs/2.2/mod/core.html#files
Adam Backstrom
2009-05-07 23:33:53
thanks so much,u saved so much of my time.
War Coder
2009-05-08 02:53:45
A:
In the .htaccess file in your directory just put
Options -Indexes
As stated before.
Edited to remove the wrong htaccess setting. Again sorry
M_D_K
2009-05-07 22:31:41