Domanda

I want to configure a multistore shop like this:

domain1

domain2

The store code approach is not possible because we need to have the same store code multiple times.

What would be the best way to achieve this with nginx?

My configuration: Ubuntu 16.04LTS, PHP7.1(FPM), nginx/1.10.3, Magento 2.2.2 CE

È stato utile?

Soluzione

I've done a setup with Magento 2.2 and nginx before, but with subdomains instead of folders.

So the setup was:

  • nl.domain1.com, en.domain1.com,...
  • nl.domain2.com, en.domain2.com,...

etc.

This is a modified version of the setup, maybe it helps you getting started. Another/additional idea: Create 2 nginx config files (one for each domain) and use alias for the subfolders?

#default mapping
map $http_host $magesite {
        127.0.0.1 "website1_storeview1";
}

map $http_host $MAGE_SUBLOCATION {
    www.domain1.com /nl;
    www.domain1.com /en;
    www.domain1.com /de;
    www.domain1.com /fr;
    www.domain2.com /nl;
    www.domain2.com /en;
    www.domain2.com /de;
    www.domain2.com /fr;
}

map $http_host $MAGE_RUN_CODE {
    www.domain1.com website1_storeview1;
    www.domain1.com website1_storeview2;
    www.domain1.com website1_storeview3;
    www.domain1.com website1_storeview4;
    www.domain2.com website2_storeview1;
    www.domain2.com website2_storeview2;
    www.domain2.com website2_storeview3;
    www.domain2.com website2_storeview4;
}

location ~ \.php$ {
    fastcgi_pass fpm:9000;
    fastcgi_intercept_errors on;
    include fastcgi_params;
    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_read_timeout 3600;
    fastcgi_param MAGE_RUN_TYPE website;
    fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
    fastcgi_index index.php;
}

I am not an nginx expert but got my setup running in the end :)

Altri suggerimenti

Using subdirectorries

Add the Language directory as subdirectories symlinking the index.php to the original one. Then detect subdirectory + domain name in the index.php to set the active storecode.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top