简体   繁体   中英

How to select directory and all subdirs

I have the following file structure:

/var/www
/var/www/subdirectory

I want to configure my apache2.conf with a directive that applies to both var/www and all it's subdirectories and files.

<Directory "var/www"> only applies to the parent directory.

Direcotry "var/www/*/"> only applies to the subdirectories.

Clarification

I am using https://github.com/h5bp/server-configs-apache to try and configure apache2.conf. I therefore want all the changes to apply to every public file served (root dir and all other files).

When I read https://github.com/h5bp/server-configs-apache , I get the understanding that var/www should apply to all subdirs, however the Options -Indexes rule clearly does not work (subdir indexes are visible). When I try var/www/* the indexes no longer show, but other rules are not applied to the root dir.

I can isolate this issue:

<Directory "var/www/*">

    <IfModule mod_autoindex.c>
        Options -Indexes
    </IfModule>

</Directory>

Disables listing of subdirs, whereas:

<Directory "var/www">

    <IfModule mod_autoindex.c>
        Options -Indexes
    </IfModule>

</Directory>

Does not.

** UPDATE 2 **

For reference, I have the following URL rewrites:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

How can I apply the directive to both, and all included files?

According to the documentation <Directory> Directive

<Directory> and </Directory> are used to enclose a group of directives that will apply only to the named directory, sub-directories of that directory, and the files within the respective directories.

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