0

I have a Drupal site installed via composer, creating a structure like

vendor/
config/
composer.json
etc/
web/core
web/themes
web/index.php
web/etc

Is there a way to change the web folder to a public_html folder so I can use it on my hosting? So the structure needs to be:

vendor/
config/
composer.json
etc/
public_html/core
public_html/themes
public_html/index.php
public_html/etc

I got it working now by using .htaccess but I started using this method with the config outside of my root folder because of the security advantages. With this method, the config is still in my root but via htaccess I point everybody to the web folder. Is this still secure enough?

So how can I change this and is it necessary?

7

You should be able to change the installer paths in composer.json, which defines where the files are placed:

"installer-paths": {
  "web/core": ["type:drupal-core"],
  "web/modules/contrib/{$name}": ["type:drupal-module"],
  "web/profiles/contrib/{$name}": ["type:drupal-profile"],
  "web/themes/contrib/{$name}": ["type:drupal-theme"],
  "drush/contrib/{$name}": ["type:drupal-drush"]
},

to:

"installer-paths": {
  "public_html/core": ["type:drupal-core"],
  "public_html/modules/contrib/{$name}": ["type:drupal-module"],
  "public_html/profiles/contrib/{$name}": ["type:drupal-profile"],
  "public_html/themes/contrib/{$name}": ["type:drupal-theme"],
  "drush/contrib/{$name}": ["type:drupal-drush"]
},

You can then rename the web folder to public_html and everything should work.

  • I don't know if it was necessary but I did a composer update after the change. But it works perfectly! – Joost Dec 11 '17 at 13:05
  • I tried this, but I reinstalled had to change a line in scripts/ as well. – petergus Jul 1 '18 at 9:07
  • 1
    When changing the paths on an existing installation, use composer dump-autoload for updating the autoload files to make it work once the paths are changed. – conceptdeluxe Oct 23 '18 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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