I would like to achieve the below URL setup in magento 2 with nginx

domain.com/us/          ->  us english store view   (us_en)
domain.com/us/de/       ->  us german store view    (us_de)

domain.com/uk/          ->  uk english store view   (uk_en) 
domain.com/uk/de/       ->  uk german store view    (uk_de)

I've created 2 websites and one store for each website and 2 store views for each store. Done the base url setup per Store View.

Tried enabling and disabling "Add Store Code to Urls". Still no luck

Note: I dont want a subdomain approach

The below nginx config doesnt work. results 404 error on magento2.

domain vhost.conf

map $request_uri $MAGE_RUN_CODE {
    default   us_en;
    ~^/us/de  us_de;
    ~^/us     us_en;
    ~^/uk/de  uk_de;    
    ~^/uk     uk_en;

map $request_uri $MAGE_RUN_TYPE {
    default   store;


location ~ (index|get|static|report|404|503)\.php$ {
    fastcgi_param  MAGE_RUN_CODE $MAGE_RUN_CODE;
    fastcgi_param  MAGE_RUN_TYPE $MAGE_RUN_TYPE;

Achieved the above structure with apache, by creating the old softlink approach. But have to get the config done in nginx.

Thanks in Advance.


  • you just need to add either rewrite or symlink – MagenX Mar 3 '17 at 10:21
  • Have you figured this out ? Have you tried to set Add Store Code to Urls = No but set Base Urls in each store configuration to example.com/us/de/, example.com/us/, .. ? – obscure Mar 9 '17 at 19:06
  • Have you figured this out, having similar problems here... – Alex Nov 29 '17 at 11:17

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.