Unusual subfolders (not subdomains) M2 setup can be achievied exactly same way M1 was done.
First of all, create store in your Magento 2 admin, then directory folder.
Two files are required for the operation. Index.php and .htaccess copied from your store.
To run certain M2 store view, it’s enough to replace:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);


$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'your_store_code'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

Then, set the store url as for subfolder and what’s most important – set base url for static view files to:


and base url for media to


Where example.com is of course your main domain name for the store.

Valid configuration for Nginx can be alike:

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork us on GitHub