1

My customer a has production environment with the following folder structure:

- www
|- maresmuseum

where I only have access to these two empty folders, being the "maresmuseum" the public_folder.

I've deployed my Drupal 9 site with composer, like the project-recommended way does, you know: placing the index.php along many other core related folders & files in "maresmuseum" folder, and /vendor, /tmp and many other private stuff in the "www" folder.

As a result, I can access my website through a url like this: https://example.com/maresmuseum (I'm quite sure my customer has a .htaccess rule somewhere to accomplish that, don't you?)

Given this production scenario, and having in mind I work with DDEV on local, I want to install this site on my local machine so I can access it with a url like this: https://example.local/maresmuseum.

Of course, all inner pages of this site must follow this url pattern, something like this:

https://example.local/maresmuseum/about-us

https://example.local/maresmuseum/contact, etc..

How should I configure DDEV to accomplish that? Thanks in advance.

rfay
  • 9,963
  • 1
  • 47
  • 89
donbuche
  • 101
  • 1
  • 3
  • 10

1 Answers1

1

I'm sure there are many ways to do this. Here's one way to do it using nginx configuration changes.

I used https://blog.rebootr.nl/drupal-8-in-a-subdirectory-with-nginx/

  1. ddev config --composer-root=maresmuseum --project-type=drupal9 --webserver-type=nginx-fpm --docroot=maresmuseum/web --create-docroot --web-working-dir=/var/www/html/maresmuseum (This sets up to put composer.json in maresmuseum)
  2. Install Drupal 9: ddev composer create drupal/recommended-project --no-install
  3. ddev composer require drush/drush
  4. Install project, or load db, or whatever, maybe ddev exec vendor/bin/drush si -y demo_umami --account-pass=admin
  5. Edit the .ddev/nginx_full/nginx-site.conf to remove the #ddev-generated and replace the location stanza, example in https://gist.github.com/rfay/5248e5f75bf3e27d84965bfdfc69c240#file-nginx-site-conf
  6. Edit the maresmuseum/sites/default/settings.php to add the stanza suggested in the article to the bottom, example in https://gist.github.com/rfay/5248e5f75bf3e27d84965bfdfc69c240#file-settings-php
  7. ddev restart && ddev launch /maresmuseum
  8. https://<project>.ddev.site/maresmuseum will work fine (as it will without the directory).

I had some trouble with browser cache, so you'll want to pay attention to that.

rfay
  • 9,963
  • 1
  • 47
  • 89