We would like to create multiple websites in Magento 2. There is an article about this topic in the Official Magento 2 Documentation, but the way they describe is not suitable for our case.
They are suggesting to use sub-domains in order to determine different websites, such as
- website1.magento-site.com
- website2.magento-site.com
We would like to use sub-folders instead of sub-domains. To give an example,
- magento-site.com/website1
- magento-site.com/website2
How can we overcome this issue on Nginx web server?
My Configuration
I am using Ubuntu 16.04. I have installed Nginx, and have not changed any Nginx core configuration. I have created a file magento-site.com.conf
inside /etc/nginx/sites-enabled/magento-site.com.conf
.
/etc/nginx/sites-enabled/magento-site.com.conf
server {
listen 8080;
server_name magento-site.com;
set $MAGE_RUN_CODE website1;
set $MAGE_ROOT /var/www/magento-site.com;
include /var/www/magento-site.com/nginx.conf;
}
EDIT 1: (2017-10-23)
I have multiple stores for each website.
Best Answer
What about a pure nginx solution with this double map ?
First, for the web site (thanks @MagenX)
A second for the new request uri
And finally, dont forget to set the new computed REQUEST_URI