Basj
Basj

Reputation: 46223

Why does Apache find the website directory automatically?

The only <Directory> I have among all Apache config files is:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Actually the real directory on server is /var/www/html/. The directory /var/www/ has no file, but only the subdir html.

So accessing the root of my website should fail, because /var/www/index.html doesn't exist. But it doesn't fail, the content of /var/www/html/index.html is displayed, even if I didn't specify it in the config file.

Why?

Upvotes: 0

Views: 30

Answers (1)

covener
covener

Reputation: 17886

<Directory> sections cover the specified directory and any subdirectory.

Something like DocumentRoot, VirtualDocumentRoot, Alias, RewriteRule, or FallBackResource could exist in an Apache config file or .htaccess that maps / to /var/www/html without any <Directory> section explicitly listing it.

Edit: if apachectl -S shows Main DocumentRoot: "/var/www/html" even if this is specified nowhere in your config files, this means that this value is compiled-in default in your Apache build.

Upvotes: 1

Related Questions