I have two websites and two domains in one installation, but the domain redirect seems not work.
map $http_host $MAGE_RUN_CODE {
a.com base1;
www.a.com base1;
b.com base2;
}
map $http_host $MAGE_RUN_TYPE {
a.com website;
www.a.com website;
b.com website;
www.b.com website;
}
nginx.conf
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
b.com always redirect to a.com
I think my settings is right, I don't where is mistake.
www.b.com works well, but if I typed b.com, it will redirect to a.com
I also configured base url for each website in dashboard.
Hello @Magentobiz_com
map $http_host $MAGE_RUN_CODE { default ''; french.mysite.mg french; german.mysite.mg german; } server { listen 80; server_name mysite.mg french.mysite.mg german.mysite.mg; set $MAGE_ROOT /var/www/html/magento2; set $MAGE_MODE developer; set $MAGE_RUN_TYPE website; #or set $MAGE_RUN_TYPE store; include /var/www/html/magento2/nginx.conf; }
map $http_host $MAGE_RUN_CODE { french.mysite.mg french; } server { listen 80; server_name french.mysite.mg; set $MAGE_ROOT /var/www/html/magento2; set $MAGE_MODE developer; set $MAGE_RUN_TYPE website; #or set $MAGE_RUN_TYPE store; include /var/www/html/magento2/nginx.conf; }
map $http_host $MAGE_RUN_CODE { german.mysite.mg german; } server { listen 80; server_name german.mysite.mg; set $MAGE_ROOT /var/www/html/magento2; set $MAGE_MODE developer; set $MAGE_RUN_TYPE website; #or set $MAGE_RUN_TYPE store; include /var/www/html/magento2/nginx.conf; }
More info check
https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_nginx.html
If works then mark as solution
Do I have to create three nginx conf files?
I modified file refer to your configuration. but it totally not working, and now whatever b.com or www.b.com both will redirect to a.com.
I have no idea
upstream fastcgi_backend {
server unix:/var/run/php-fpm/www.sock;
}
map $http_host $MAGE_RUN_CODE {
default '';
a.com base;
www.a.com base;
b.com base1;
}
server {
listen 80;
server_name a.com www.a.com b.com www.b.com;
set $MAGE_ROOT /website/magento;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE website;
include /website/magento/nginx.conf;
}
/website/magento/nginx.conf:
..........................
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600;
fastcgi_connect_timeout 600;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_index index.php;
..........................
Please change your $MAGE_RUN_CODE to another name. Ex: $MAGE_RUN_CODE_AB
And update it in nginx.conf also.
The problem is you are using $MAGE_RUN_CODE in another server configuration.