I will have 3 websites (each with their own website/store/store view), but at the moment they are all on one test site example.com. I want a Spanish and French language, I have that working, but instead of going to example.com/es/ I have to go to example.com/es/es/.
I have set Add Store Code to Urls
to yes because if I don't then the /es
won't work. The base url of the Spanish site is set to example.com/es/. If I use {{config path="web/unsecure/base_url"}}
then it will only link to example.com/es/
and that won't load the page.
I did create an es folder and symlink app, bin, dev, lib, pub, setup, update, var, vendor
and copied the .htaccess and index.php file into that folder. The .htaccess is the default Magento 2 one and in the index.php I put in
Here is the index.php file:
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'es';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
Eventually the websites will be access via example.com, example.es, and example.fr. For testing purposes I need them to be accessible from example.com, example.com/es/, and example.com/fr/. I am unsure what is the issue with the url.
EDIT:
The following will return example.com/fr/fr/
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$baseUrl = $storeManager->getStore()->getBaseUrl();
While:
{{config path="web/unsecure/base_url"}}
will only return example.com/fr/
.
Why does {{config path="web/unsecure/base_url"}}
not return the same url as the php example?