Score:0

apparently apache retrieves index.php from non existent directory

th flag

I have a web site defined in apache2 with the conf file:

<VirtualHost *:80>
    ServerName my.site.net
    DocumentRoot /var/www/foto
    <Directory /var/www/foto>
        DirectoryIndex index.php
        Options +FollowSymLinks
        Options -Indexes
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

Everything is fine, but:

  • If I load my.site.net/non-existent-directory (without the trailing slash), the /var/www/foto/index.php file is loaded, and all the files which are loaded by index.php are found

Why is /var/www/foto/index.php loaded? I'd expect a not found error.

How is non-existent-directory interpreted?

  • if I load my.site.net/non-existent-directory/ (with the trailing slash), the /var/www/foto/index.php file is loaded, Loading it, the files which should be loaded by index.php are not found, because are searched in the non existent directory.

Again, why is /var/www/foto/index.php loaded?

What should I do in order to avoid it?

Edit: removed trailing slash from DocumentRoot and upgraded order allow,deny, allow from all to Require all granted

in flag
Do you have an .htaccess file in /var/www/foto?
Chris avatar
it flag
The .htaccess file is not relevant, `AllowOverride None` in vhost prevents them to be loaded. From doc, *The `DocumentRoot` should be specified* ***without a trailing slash***. I would try first to remove the trailing slash. Also note the `order allow,deny, allow from all` directives are apache2.2 synthaxe. You should try to use [the apache2.4 synthaxe](https://httpd.apache.org/docs/2.4/en/howto/access.html) (`Require all granted`)
th flag
removed the trailing slash, nothing changed
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.