I'm trying to setup swimmersmall.com and swimmersmall.net using the same Magento 2 directory. I setup wimmersmall.net as a add-on domain under wimmersmall.com. Both pointing to the same directory.
I have been trying to setup this using the documentation here.
I want all the sessions and shipping to be the same, so I kept both 'stores' under the same 'website' in the admin panel. I setup the store view on the second store also.
swimmersmall.com is the primary site which is working great. When I get to the page on the documentation under "Set up multiple websites with Apache", I am a bit confused. I follow the directions but get a page error.
The index.php on root:
$params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'swimmersmall'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\Framework\App\Http');
.htaccess file:
RewriteCond %{HTTP_HOST} ^(.*)swimmersmall\.net RewriteRule .* – [E=MAGE_RUN_CODE:allamericanswim RewriteCond %{HTTP_HOST} ^(.*)swimmersmall\.net RewriteRule .* – [E=MAGE_RUN_TYPE:store]
Here I am a little confused. I get a Internal Server Error (500) error. I'm unsure what the above code does in the index.php and how it would even know to load one store verses the other.
Any suggestions?
Hi, I've setup multiple websites & stores on one of our test environments. I didn't need to make any changes to index.php or .htaccess
I simply added .conf files for each storefront in my /sites-enabled folder of my apache server (in my case as I use php7 it is /etc/httpd/sites-enabled)
# the port number depends if you use varnish or not <VirtualHost *:8080> # config here for host X - update this, and save it as <name>.conf ServerName <domainname> DocumentRoot /var/www/html/<magento2foldername> SetEnv MAGE_MODE "production" SetEnv MAGE_RUN_TYPE "store" SetEnv MAGE_RUN_CODE "swimmersmall" RemoteIPHeader X-Forwarded-For </VirtualHost>
This is an example above of what I did - and it works nicely - port number depends if you got varnish or not
my httpd.conf file in etc/httpd/conf/ folder contains the following in <Directory "/var/www/html">
<Directory "/var/www/html"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Require all granted </Directory>
Also make sure your *.conf files in /sites-enabled gets loaded
this is at the end of my httpd.conf in /etc/httpd/conf/ folder
# Load config files in the "/etc/httpd/conf.d" directory, if any. IncludeOptional conf.d/*.conf IncludeOptional sites-enabled/*.conf
I use PHP7 so that's why I've got httpd for my apache folder, you may see your apache conf file in /etc/apache2/conf/ folder instead
I hope that helps
Hi,
We need to create several website in magento with different domain name. All domains need to be on the same magento instance.
Example :
http://www.site1.com/fr/
http://www.site1.com/en/
http://www.site2.com/fr/
http://www.site2.com/en/
http://www.site3.com/fr/
http://www.site3.com/en/
What is your advice on the best practices to made them ?