1

I have 2 domains I want lunch it with the same Magento as a multi-website option in Magento. I add (website, store, view store ) and associated it with the second domain. I change my .hatacsses in root Magento(first domain) like that

#SetEnv MAGE_MODE developer
SetEnvIf Host .*nasseij.com.* MAGE_RUN_CODE=base
SetEnvIf Host .*nasseij.com.* MAGE_RUN_TYPE=website
SetEnvIf Host .*test.nasseij.com.* MAGE_RUN_CODE=sinwadi
SetEnvIf Host .*test.nasseij.com.* MAGE_RUN_TYPE=website

and

#RewriteBase /magento/
RewriteCond %{HTTP_HOST} ^(.*)nasseij\.com
RewriteRule .* – [E=MAGE_RUN_CODE:base]
RewriteCond %{HTTP_HOST} ^(.*)nasseij\.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} ^(.*)sinwadi\.com
RewriteRule .* – [E=MAGE_RUN_CODE:newsite]
RewriteCond %{HTTP_HOST} ^(.*)sinwadi\.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website]

and change this in the main index of my basic Magento

require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'base';
$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::class);
$bootstrap->run($app);

and put .hatccses in second domain root but didn't work it gives me that file not found. I try copy Magento files to second domain root also give me that 500 error a lot of redirects

Do I want to know my mistakes and in the second domain which files have to be?

0

If you are doing this in your .htaccess, you do not need to also edit your index.php file. Additionally, the conditions you have specified with SetEnvIf overlap each other.

Remove all of your rules from the .htaccess file and save them in a text pad in case you need them later. Remove your changes to index.php. Right after the line RewriteEngine on, try this:

SetEnvIf Host ^nasseij MAGE_RUN_CODE=base
SetEnvIf Host ^nasseij MAGE_RUN_TYPE=website
SetEnvIf Host ^test\.nasseij MAGE_RUN_CODE=sinwadi
SetEnvIf Host ^test\.nasseij MAGE_RUN_TYPE=website

OR if your main domain begins with www, try this:

SetEnvIf Host ^www\.nasseij MAGE_RUN_CODE=base
SetEnvIf Host ^www\.nasseij MAGE_RUN_TYPE=website
SetEnvIf Host ^test\.nasseij MAGE_RUN_CODE=sinwadi
SetEnvIf Host ^test\.nasseij MAGE_RUN_TYPE=website

Depending on whether apache is looking at index.php or pub/index.php, you will need to do this in either the .htaccess file in the root of your Magento installation or the .htaccess that lives inside of the pub directory.

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.