Earlier quoted context omitted.
You seem to imply this is a novel attack vector. But it's really just an instance of a very old mistake: Don't use the root of your app as document root! It's really as simple as that. Almost all modern apps have a subdirectory "public/" or similar. That one is meant to be used as document root. You only have to ensure there are no sensitive files in there . If you fail to introduce such a directory, you'll have a ga…
Great point. How much do you want to bet most of these are PHP, where it takes special discipline not to make your top directory web-accessible?
.git
web/index.php
src/*.php
Make the document root /full/path/to/web/index.php.Edit: Also use a deployment tool like Capistrano which removes the .git directory as well.