I was just wondering if it was possible to protect a directory with a username/password combination using .htaccess and .htpasswd files, but not protect the files within. i.e. One is able to link, say, images within that directory to friends, but browsing the directory itself would not be allowed without a username/password. Thanks to all in advance.
|
feedback
|
|
You want to just turn off displaying Apache the index of the folder. Put this in the .htaccess:
This way when Users visit | |||
|
feedback
|
|
Do a chmod 777 on the files, but not on the main folder. | |||||
feedback
|
|
If you want the directory listing to be visible to only authroized users but allow anyone to download a file (so you can send people links), then you need a script of some type (PHP, ASP, etc.) which asks the user for a password and if they get it right displays the contents of the directory. You would put this script in the directory and name it as index.php so it gets served rather than apache generating a directory index. | |||
|
feedback
|
|
Yes, you can secure files and directories by name or pattern. You should already by using this to restrict access to the .ht* files. Check your apache configuration. The required file pattern will likely be '/$'. | |||
|
feedback
|
|
Use | |||||
feedback
|
|
Yes. Add an index.html file that lists the contents of the folder and restrict access to that file with .htaccess. If you want the index to be dynamic you'll need to use some sort of script (or server side include) to generate the index. | |||
|
feedback
|
|
Try this in your
Here In the amended rules for files, the key is So now browsing this directory or any of its subdirectories will require a login, but directly retrieving a file from it won’t. Which is what you wanted. | |||
|
feedback
|