I've read through the Magento 2 multistore help guide in a bid to understand it, but it is a bit too much for me to take in so I need a little help dumbing it down.
Essentially what I am trying to achieve is:
For SEO purposes the USA/Canada stores needs to be a subdirectory, not a subdomain. i.e.
UK/EU: www.domain.com (primary)
USA/Canada: www.domain.com/us (subdirectory)
I have GeoIP installed on the site at the moment, so having customers redirected to the correct site won't be a problem.
PS: I will probably also make two further stores (but with a lot less products and a different layout):
UK/EU Wholesale: www.domain.com/wholesale(subdirectory)
USA/Canada Wholesale: www.domain.com/us/wholesale(subdirectory)
First You need to create sub-folder like us in Magento root.
then copy the Index.php and .htaccess from root to this sub-folder.
update Index.php in sub-folder
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
with below code
$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 sub-folder and
what’s most important – set base URL for static view files to:
domain.com/pub/static
and base URL for media to
domain.com/pub/media
Where domain.com is of course your main domain name for the store.
You can repeat same above step for all new stores like wholesale etc.
Thank you very much for taking the time to reply!
I have done the first part with creating the subfolders and stores but I'm not sure what exact steps to take here:
what’s most important – set base URL for static view files to:
domain.com/pub/static
Is this setting in the Configuration section of the Admin panel?
and base URL for media to
domain.com/pub/media
I'm not entirely sure what this means. I should probably point out that I'm not a developer, I'm new to Magento (having moved over from Opencart).
Hi,
what’s most important – set base URL for static view files to:
domain.com/pub/static
means when you set admin URL configuration in Store > Configuration > General > Web > Base URLs section
For Base URL put subfolder domain URL like www.domain.com/us but for other static URL must put the main domain URL only not with sub-folder URL
like check below screenshot
http://prntscr.com/mqswnw
http://prntscr.com/mqsyrd
Hope this will help you.
Thanks
Hello,
Thanks for taking the time to reply. So are you saying that I need to change the below to actual URLs and then change the base URL? Or is the below fine so long as the actual subdirectory is correct (i.e. subdirectory is www.domain.com/us). I just want to be clear before I change the base URL.
Yes first you need to select your particular store like US store and then update URL like below screenshot.
https://prnt.sc/mqsyrd
Thank you. I attempted this action but received the below error.
Has anyone experienced this?
Has anyone encountered this issue and been able to fix it?
For anyone else having this issue I figured it out. I had to add / at the end of the URL.
i.e.