My drupal project is in directory /var/www/MY_ORGANIZATION/MY_PROJECT/current, and apache2 is configured to point the web subdirectory of the above location. When I access the site, it is of course under http://www.myorganization.it/. Now I need to move it to http://www.myorganization.it/myproject, both for organization policies and to allow it to be more easily reached through a reverse proxy. I searched around and I found a couple of interesting links, like this and this and a few more. Inspired by them, I tried to move the contents of web/ to web/myproject, but when I accessed http://www.myorganization.it/myproject I got blank page. The error in the logs is crystal clear:

Failed opening required '/var/www/MY_ORGANIZATION/MY_PROJECT/current/web/myproject/../vendor/autoload.php' 

So I put back the installation in web/ and renamed it to myproject, changed apache configuration to point /var/www/MY_ORGANIZATION/MY_PROJECT/current, and that worked like a charm. But I am not sure this is an advisable configuration, since, well, since all Drupal installations I saw were in a web directory. Also, from my research I had understood that Drupal installation can be moved to arbitrary subdirectories, but I didn't find any official documentation. It would appear that I should at least configure a path for vendor.

So, the concluding question is, would you recommend simply renaming web to myproject, or should I do it another way?

EDIT: a symlink from myproject to web seems an elegant solution, it works fine in apache (dev environment), while I'm getting errors with nginx+php-fpm (staging environment); still, it may be the way to go.

  • To clarify the error message you're seeing in the log: this is coming from PHP rather than Apache. When index.php is run it (indirectly) looks for a file with the relative path ../vendor/autoload.php. If the contents of web are moved, this relative path to ../vendor stops being correct. Mar 31, 2020 at 15:58

1 Answer 1


Apache can handle this. You can leave the Drupal code where it is.

Have a look at the Apache documentation for Mapping URLs to Filesystem Locations. In particular, the differences between DocumentRoot and Alias.

In the absence of any other information, Apache looks for files/scripts in the document root. For a Drupal site located at https://www.myorganization.it/, it's enough to point DocumentRoot at the web directory. Apache will find index.php there.

But myproject isn't a directory in the filesystem. So you need to explicitly tell Apache about it, that any URL starting /myproject refers to the web directory. You can do that with the Alias directive:

Alias "/myproject" "/var/www/MY_ORGANIZATION/MY_PROJECT/current/web"

You'll also want to point DocumentRoot somewhere else to stop Drupal being visible at the root too (an empty directory will do).

  • Yes, I know, but then all the links to static files will be wrong, and I'd have to set file_public_base_url to change that; it seems easier to me to just put everything in a separated directory, from my research it appears to be a supported configuration, but it's not clear to me what is the recommended way to do it. Mar 30, 2020 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.