-
I'd like to setup Drupal multisite using a subdirectory in DDEV to match the server configuration. So, the main site is abc.ddev.site, and the multisite would be abc.ddev.site/xyz/ I've setup the symlink from web to xyz, and there are rewrite rules in .htaccess to handle clean URLs: - RewriteCond %{REQUEST_FILENAME} !-f When hitting abc.ddev.site/xzy/ the page loads fine, and looking inside DrupalKernal.php the script_name ($request->server->get('SCRIPT_NAME'); ), I see ./xyz/index.php However, any subpages, e.g. abc.ddev.site/xyz/user the script name is just ./index.php and the the main default site is loaded with a 404. Is there anything I am missing? Perhaps it's not DDEV, but the same setup works on our hosting server (Acquia). Many thanks for readying |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
First, DDEV's default webserver is nginx, where any .htaccess is irrelevant. If you have set your webserver_type to apache-fpm, then the .htaccess does take effect (but shouldn't be needed) Second, in general, Drupal multisites don't require you do do anything for the subsites. It's Drupal that does the routing for subsites, not the webserver. Some resources for Drupal multisite in Drupal:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply. I’ll see if I can change the server to make a difference. It all works apart from the clean URLs so that’s a good place to start as sub directory multi sites are tricky! Sub domains always work perfectly well on ddev.
Thanks again for the reply and all you work to create this project.
Sent from my mobile. Not guaranteed to be free from typos!
|
Beta Was this translation helpful? Give feedback.
-
Thanks - I’ll keep trying and update here when I get it to work :-). If there is anything specific that needs to be done in ddev I can add some documentation too.
|
Beta Was this translation helpful? Give feedback.
-
Hi again, just an FYI. Thanks for a pointer about nginx. That helped. Firstly, changing the server type to apache-fpm resolved it and everything worked as expected. So I checked the server type back to nginx, and in the nginx config added thes lines below the default location config (and removed the autogenerated comment line of course): - location / { location /xyz/ { P.S. If there's a more compliant way to do this, e.g. adding something extra to the config.yaml, please let me know. Editing the auto-generated file may not be the best approach. Thanks again for taking the time to support on this. |
Beta Was this translation helpful? Give feedback.
-
It just because of the sub directory mapping and URL rewriting. I’ve got loads of sites working perfectly in DDEV when it’s sub domains. Sub folders is different because of the way the kernal interprets which base url is being used, hence the additional rewrite requirement.
|
Beta Was this translation helpful? Give feedback.
-
Thank again for taking the time to reply. I did try adding the snippet to a separate file but then it gets gateway timeouts on the subdirectory site. To give a little more context, Line 413 (possibly different depending on the exact version of core, DrupalKernel has this line of code: -
Beyond these lines is where is checks for the sites by using $site_id, which becomes 'abc.ddev.site' without the addtional lines. The SCRIPT_NAME global always defaults to the default site if there are additional parts to the URL, e.g. abc.ddev.site/xyz/user. Adding the lines in htaccess for apache, or the extra location lines for nginx seems to resolve it. $site_id becomes abc.ddev.site.xyz because the SCRIPT_NAME variable contains /xyz/index.php and the parts array gets exploded correctly. On Drupal.org, the documentation explains how to do it for apache, but not nginx. (See here - https://www.drupal.org/docs/7/multisite-drupal/multi-site-in-subdirectories - for D7 but the same applied to D8+). If you think there's something missing from the sites setup I'm happy to explore some more, but I'm equally happy to contribute to the documentation on ddev. I can amend the D.O pages to include the nginx requirements too. |
Beta Was this translation helpful? Give feedback.
Hi again, just an FYI. Thanks for a pointer about nginx. That helped. Firstly, changing the server type to apache-fpm resolved it and everything worked as expected.
So I checked the server type back to nginx, and in the nginx config added thes lines below the default location config (and removed the autogenerated comment line of course): -
location / {
absolute_redirect off;
try_files $uri $uri/ /index.php?$query_string; # For Drupal >= 7
}
location /xyz/ {
absolute_redirect off;
try_files $uri $uri/ /xyz/index.php?$query_string; # For Drupal >= 7
}
P.S. If there's a more compliant way to do this, e.g. adding something extra to the config.yaml, please let me know. Editing the auto-generat…