cancel
Showing results for 
Search instead for 
Did you mean: 

Switch store doesn't work and breaks admin

SOLVED

Switch store doesn't work and breaks admin

Hello,

 

I have a fresh magento 2 install, on nginx.

I have 2 stores to run, a .fr and a .co.uk. I changed the basic url in the admin, and added this in my nginx config :

 

map $http_host $MAGE_RUN_CODE {
    .sofa-chic.fr sv_sc_fr;
    .sofa-chic.co.uk sv_sc_uk;
}

and:

 

location ~ (index|get|static|report|404|503)\.php$ {
    try_files $uri =404;

    fastcgi_param  MAGE_RUN_TYPE store;
    fastcgi_param  MAGE_RUN_CODE $MAGE_RUN_CODE;
    ...
}

 

When I switch stores in the frontend, it stays on my main store (which is the .fr), but then I try to access my admin and it redirects me to the .co.uk, so obviously it doesn't work.

 

Would you have any idea about what's going on please?

 

Regards,

 

François

1 REPLY

Re: Switch store doesn't work and breaks admin

Fixed with:

 

map $http_host $MAGE_RUN_CODE {
    hostnames;
    .sofa-chic.fr sv_sc_fr;
    .sofa-chic.co.uk sv_sc_uk;
}