0

We've Drupal multi-site (with different domain per site) running with single Drupal 8 code base and nginx. Now we wanted to setup Drupal Milti-site with sub-directory for few websites in following format :

  1. http://site1.com (Drupal multi-site, served from "sites/site1.com")
  2. http://site1.com/subdirectory (Drupal multi-site, served from "sites/site1.com.subdirectory")
  3. http://site2.com (Drupal multi-site, served from "sites/site2.com")
  4. http://site2.com/subdirectory (Drupal multi-site, served from "sites/site2.com.subdirectory")

We're running these websites on Nginx on CentOS. We've been able to get the sub-site working in following structure (but not with above structure) :

  1. http://site1.com (Static HTML page)
  2. http://site1.com/subdirectory (Drupal multi-site)

Following are nginx virtual host configuration we're using.

NOTE : I've updated nginx config to remove SSL.

# VHOST Config.
server {
  listen 80;
  server_name site1.com;

  root /var/www/html;
  index index.php index.html index.htm;

  # Prevent files from being accessed.
  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }
  location ~ /\.htaccess*$ {
    return 403;
  }
  location ~ (^|/)\. {
    return 403;
  }
  location ~ .*\.config$ {
    return 403;
  }
  location ~ /composer.*$ {
    return 403;
  }
  location ~ \..*/.*\.yml$ {
    return 403;
  }

  location / {
    try_files $uri $uri/ =404;
  }
  location @rewrite {
    try_files $uri /subdirectory/index.php?$query_string;
  }
  location /subdirectory/ {
    try_files $uri $uri/ @rewrite;
  }

  location ~ '\.php$|^/update.php' {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
  location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
    proxy_cache_bypass 1;
  }
}

Any help is greatly appreciated.

Your Answer

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

Browse other questions tagged or ask your own question.