Multisite setup based on paths is broken

Created on 2 March 2017, over 7 years ago
Updated 31 January 2023, over 1 year ago

Problem/Motivation

According to Multisite Mapping with Drupal β†’ It is possible to create a multisite setup without symlinks that is based on paths, for example

http://dev.example.com/site1
http://dev.example.com/site2

But the code that should handle that scenario is completely broken:

    // Otherwise, use find the site path using the request.
    $script_name = $request->server->get('SCRIPT_NAME');
    if (!$script_name) {
      $script_name = $request->server->get('SCRIPT_FILENAME');
    }
    ...
    $uri = explode('/', $script_name);

SCRIPT_NAME always returns index.php and SCRIPT_FILENAME returns the real path in the file system which is obviously the same for site1 and site2 as long as you don't create any symlinks and virtual hosts for every site. According to the documentation that was the case for Drupal 7 and that's where the code comes from:

By sharing the same drupal code base as above (/public_html/drupal) , you may extend the Subdomain Mapping where you can set another drupal sites under URL's Paths like so:

http://dev.example.com/site1,
http://dev.example.com/site2, etc..

Symbolic Links

First you will need to access your server shell. Then create the symbolic links to the drupal root folder named site1 and site2 by following command:

$ cd /path/to/your/public_html/drupal
$ ln -s . site1
$ ln -s . site2

For Drupal 8 the documentation states something else (which makes a lot of sense):

Multi Drupal Sites (By Drupal 8)

By Drupal 8 the symbolic links are no more required, there even a flexibility to name the folders under /public_html/drupal/sites as long you put them on the file sites.php like:

$sites = array(
'dev.example.com' => 'dev',
'dev.example.com.site1' => 'dev.site1',
'dev.example.com.site2' => 'dev.site2',
);

Proposed resolution

In Drupal 8 the algorithm must simply use REQUEST_URI instead of SCRIPT_FILENAME.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
BootstrapΒ  β†’

Last updated 9 days ago

No maintainer
Created by

πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡·Argentina gerzenstl Resistencia

    I believe that instructions for Multisite setup based on paths are incomplete or maybe needs more work.

    I was able to make this work with D9 and NGINX, but I needed to read not only the docblock in sites.php and the docs β†’ . I also read several blog posts to understand how to set virtual host to work with this approach (and I'm still looking if there is a way to avoid using symbolic links).

    I think the current issue where is tracked the documentation improvements is this one β†’ . Are there any other issue mentioning something about this multi-site approach?

Production build 0.69.0 2024