1

There is absolutely no problem to have multi sites, where:

  • domain1.com points to site A
  • domain2.com points to site B

But I want to have multi-site setup, where:

  • domain1.com points to site A
  • domain1.com/blabla points to site B

I was doing everything to solve it, for example using directory structure like that:

  • domain1.com
  • domain1.com.blabla

or using file sites.php with content:

$sites = array(
'domain1.com' => 'domain1.com',
'domain1.com' => 'domain1.com.blabla',
);

Nothing works, site 'domain1.com' takes all traffic.

FYI:

  • I'm using nginx.
  • I'm using Drupal 7.
  • I do not want to use the module Domain as I want to have separated databases.

Please help!

2

I have done this before. Given a generic location / { ... } entry for Nginx which serves domain1.com to make the subdirectory install work I did the following 2 steps. I am not aware of a solution that doesn't involve making a symlink.

Step 1:

In your Nginx configuration:

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            index index.php;
            try_files $uri $uri/ @rewrite;
            expires max;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location /blabla {
     try_files $uri $uri/ /blabla/index.php?$args;
    }
    location ~ /blabla/.+\.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
            webuser /usr/share/nginx/html;
    }

Step 2:

Then wherever your docroot is for your site you add an alias with your subfolder name to the main docroot, allowing the path to be valid for Drupal:

$ pwd
/usr/share/nginx/html

user@localhost:/usr/share/nginx/html$ find . -type l -ls
41059    0 lrwxrwxrwx   1 webuser    webuser           21 Sep 25 01:58 ./blabla -> /usr/share/nginx/html

You will still need your sites.php configuration as you have listed. You will need to restart Nginx.

  • try_files $uri $uri/ /blabla/index.php?$args; was crucial, it works fantastic! I was doing many combinations before, but it is a perfect solution, thanks a lot! – Serge Victor Dec 2 '15 at 5:14

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.