Instead of fixing what I wanted (subdirectory handling), I worked with installation instead.
There are quite a few tickets opened but this is the one which wasted most of my time. The result is pretty good though: now it’s possible to install Danbooru without giving superuser privilege to the database account used. Installation still requires one though.