Score:0

Apache 2.4 block all directories in root except for two specified

gn flag

I want to block all directories in the document root except for two.

I don't want to manually block the ones I don't need. Instead, I just want to specify the two to keep.

I have a list of folders and files structured like this:

- Docs
- Docs_Files
    Img1.jpg
    Img2.jpg
    Img3.png
    Test.jpg
    TestLarge.png
    Zones.bmp
- Images
    A1.jpg
    B5.jpg
    B5.png
    X7.png
- Report 1
- Report 2
- Report 3
…
- Report 25

I’d like to just grant access to the Docs_Files directory and the Images directory and deny everything else, without having to specify every new folder that gets added (same idea with file types of jpg). My attempt at doing this didn’t work:

DocumentRoot "b:"

<Directory "b:">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory "b:/Docs_Files">
    AllowOverride None
    Require all granted

    <Files *>
        Require all denied
    </Files>

    <Files *.jpg>
        Require all granted
    </Files>
</Directory>

<Directory "b:/Images">
    AllowOverride None
    Require all granted

    <Files *>
        Require all denied
    </Files>

    <Files *.jpg>
        Require all granted
    </Files>
</Directory>

Any suggestions? Thanks!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.