简体   繁体   中英

Apache: How do I open up read access to a directory & its contents, giving a directory listing, but not write access?

Around two decades ago, I did this, but I can't seem to figure it out now. I think Apache requires a directive - best in a <Directory> container - else it thinks opening up file permissions is a configuration error, but I don't know how to do it today.

To clarify, what I want to do is point a link to a directory with no html files and let the user browse the files that are there and download, "read," but with no write access. If it's in that directory, it's there to be read by anyone, just no new files and no changes to existing files.

Over clearer thinking of coffee the next morning I realized a great help could be found back in the httpd.conf, and sure enough there was a comment there about this and it pointed to this in the docs.

I then realized what's needed is to add an exception for the directory for "Indexes", described as:

> Indexes
>     If a URL which maps to a directory is requested and there is no DirectoryIndex (e.g., index.html) in that directory, then
> mod_autoindex will return a formatted listing of the directory.

So...

I tried just:

<Directory "/the/dir">
   Options Indexes
</Directory>

Then $ apachectl graceful

And then tried it again, and success!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM