Multistore in subfolders setup in Nginx

in Nginx configuration Tags: MagentoNginx

A lot of our customers use a Magento multistore set-up by using multiple domains that connect to different storefronts on their Magento installation. It is however also possible to create a Magento multistore by using subfolders for the individual storefronts. If you want to do this, you can use articles like this one to set up this configuration. On Hypernode, there is only one thing that will work differently for this particular setup. On Hypernode you can’t use .htaccess files but instead you’ll have to adjust some settings in your Nginx configuration.

You’ll have to add the next lines of code to your handler.conf that’s located in the nginx folder on Hypernode:

location ~ ^/(?<uri_prefix>(shop_de|shop_fr|shop_nl)) {
    rewrite / /$uri_prefix/index.php break;
    echo_exec @phpfpm;

In the example you’ll have to adjust the shop_de|shop_fr|shop_nl to the subfolders you are using in your webdirectory.

Setting locations and handlers are on a request base. This means that it is not possible to define a handler for a php file. If a php file is used in every request, it’s not possible to set a custom handler for solely this file.