2

Anybody knows how to use the following piece of code? I want detect visitors browser language and than redirect for the right multi language store. Want to use subfolders (www.domain.com/en/), not multi (www.en.domain.com) domains.

require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
0

To detect browser language check here: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php.

Depending on the found valid language you can set your store view code as PARAM_RUN_CODE and "store" as PARAM_RUN_TYPE.

To edit the used base URL, check this out: Link store view to different Url in magento 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.