Magento 2.1.7 how to get different domain name for different stores
-
29-01-2021 - |
Вопрос
How can i get different domains name for different stores created. Created store name as French its domain name should be fr.domainname.com.Thanks in advance..
Решение
Step 1: Create websites
- In your Magento backend, go to
Stores > Settings > All Stores
- On the Stores page, click Create Website.
- Name: Enter a name to identify the website.
- Code: Enter a unique code; for example, if you have a French store, you can enter
french
- Sort Order: Enter an optional numerical sort order.
Click Save Web Site.
Repeat these tasks as many times as necessary to create your websites.
Step 2: Create stores
- In your Magento backend, go to Stores > Settings > All Stores.
- On the Stores page, click Create Store.
Web Site: Select the website with which to associate this store. Name: Enter a name to identify the store. Root Category: Select the root category for this store.On the Stores page, click Create Store.
- Click Save Store.
- Repeat these tasks as many times as necessary to create your stores.
Step 3: Create store views
- In your Magento backend, go to Stores > Settings > All Stores.
- On the Stores page, click Create Store View.
Store: Select the store with which to associate this store view.
Name: Enter a name to identify this store view.
Code: Enter a unique name to identify this store view.
Status: Select Enabled.
Sort Order: Enter an optional numerical sort order.
Click Save Store View.
Repeat these tasks as many times as necessary to create your store views.
Step 4: Change the website’s base URL
In your Magento backend, go to Stores > Settings > Configuration. Under General section, click Web.
From the Store View list at the top of the page, select a website.
Expand Base URLs section.
- Enter this website’s URL. For example: https://subdomain.example.com/
- Click Save Config.
- Repeat these tasks for other websites.
Step 5: Add the store code to the base URL
Magento gives you the option to add the store code to the site’s base URL, which simplifies the process of setting up multiple stores. Using this option, you don’t have to create directories on the Magento file system to store index.php and .htaccess.
This prevents index.php and .htaccess from getting out of sync with the Magento codebase in future upgrades.
- In your Magento backend, go to Stores > Settings > Configuration. Under General section, click Web.
- From the Store View list at the top of the page, select Default Config.
- Expand Url Options section.
- Uncheck the Use system value box next to Add Store Code to Urls. Then set this to Yes.
- Click Save Config.
- If prompted, flush the Magento cache. (System > Cache Management).
Step 6: Change the default store view’s base URL
You must perform this step last because after it’s done, you’ll lose access to the Magento Admin; your access returns after you set up virtual hosts as discussed in the web-server-specific topics.
- In your Magento backend, go to Stores > Settings > Configuration. Under General section, click Web.
- From the Store View list at the top of the page, select Default Config. Expand Base URLs section.
- Enter your website’s base URL. For example: https://www.example.com/ Click Save Config.
Step 7: It’s done! You have successfully set up multiple websites and stores in Magento 2