hi.
i have a "downloads" directory in my site that contain files ...
i need to prevent directory listing directly from the browser
ex.
http://mysite/downloads/
but i need to enable it when i call it inside the index.html
ex. <A href="/downloads/">downloa
ds</A>
how to do such thing.
Note: i have succeded to prevent direct access to files of type jpg like this:
http://localhost/downloads/sample.jpg
(htaccess)
RewriteCond %{HTTP_REFERER} !^
http://(www\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^
http://(www\.)?localhost.*$ [NC]
RewriteRule \.(exe|jpg)$ - [F]
but how to create an expresion for the whole folder , mean to disable access when access from
http://mysite/downloads/ but enable it from <A href="/downloads/">downloa
ds</A>
please help
thanks a lot
If you want to show the files in a directory with browsing disabled by htaccess (or by httpd.conf - you can turn off DirectoryIndex in Options too) then you will need to script something to read the directory and dynamically build the page. It's very easy in PHP if you have that installed on your server. Here is a sample script:
Open in new window