Question

Followed instructions at (https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies) to install Drupal with Composer using the command:

"composer create-project drupal/recommended-project my_site_name_dir"

Composer download all the files and displayed that Drupal was ready to install. However, when trying go to the page in a browser get "Forbidden You don't have permission to access / on this server. "

Looking in the "my_site_name_dir" there is no .htaccess file so the server doesn't know to go into the "/web" subdirectory. The "my_site_name_dir" directory has only the following files: /Vendor /web .editorconfig .gitattributes composer.json composer.lock

Should the .htaccess file be created automatically by Composer? I thought Composer used to do this in earlier installations. Is there a recommended .htaccess template to use. Thanks.

Environment: Windows 10, PHP Version 7.1.20, Apache 2.4

Was it helpful?

Solution

Both drupal-composer/drupal-project and drupal/recommended-project create Drupal installations with a relocated DOCROOT, or web root. So, the .htaccess folder isn't in the root of the installation.

You need to point Apache to the 'web' directory, which is where the .htaccess and index.php files are. This is done at the Apache config level, not .htaccess level.

For example, on one of my servers, I have my git checkout in /var/www/prod. The config looks like

DocumentRoot /var/www/prod/web
<Directory /var/www/prod/web>
  AllowOverride All
  Options -Indexes
  Options +FollowSymLinks
  Require all granted
</Directory>
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top