0

I have the fallowing domains:

www.test1.mydomain1.com
www.test2.mydomain2.com

I've created the websites and the stores that are attached to them. From the admin panel I changed the Base URL and Base URL Link of website1 to

http://test1.mydomain1.com

And for website2 to

http://test2.mydomain2.com

In pub/index.php I added the fallowing

$test1 = array('test1.mydomain1.com');
$test2 = array('test2.mydomain2.com');
if(in_array($params['SERVER_NAME'],$test1)){
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website1';
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
}
else if(in_array($params['SERVER_NAME'],$test2 )){
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2';
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
}

Still, when I go to www.test1.mydomain1.com everything is broken. The CSS and javascript files are not loaded apparently, and the console in dev tools shows errors like:

GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/css/animate.css 
(index):18 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/css/styles-m.css 
(index):21 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/owl.carousel/assets/owl.carousel.css 
(index):20 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/bootstrap/css/bootstrap-theme.css 
(index):17 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/mage/calendar.css 
(index):19 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/bootstrap/css/bootstrap.css 
(index):24 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/icon-fonts/css/porto-icons-codes.css 
(index):25 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/icon-fonts/css/animation.css 
(index):27 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/Smartwave_Filterproducts/css/filterproducts.css 
(index):23 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/fancybox/css/jquery.fancybox.css 
(index):26 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/css/custom.css 
(index):28 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/css/styles-l.css 
(index):131 GET http://test1.mydomain1.com/media/porto/configed_css/design_mshop_swe.css 
(index):132 GET http://test1.mydomain1.com/media/porto/configed_css/settings_mshop_swe.css 
(index):30 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/requirejs/require.js 
(index):31 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/mage/requirejs/mixins.js 
requirejs-config.js:18 Uncaught TypeError: require.config is not a function(anonymous function) @ requirejs-config.js:18(anonymous function) @ requirejs-config.js:19(anonymous function) @ requirejs-config.js:601
(index):34 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/bootstrap/js/bootstrap.min.js 
(index):35 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/fancybox/js/jquery.fancybox.js 
(index):33 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/jquery.js 
(index):42 Uncaught TypeError: require is not a function(anonymous function) @ (index):42
(index):134 Uncaught TypeError: require is not a function(anonymous function) @ (index):134
(index):143 Uncaught TypeError: require.config is not a function(anonymous function) @ (index):143
(index):362 Uncaught TypeError: require is not a function(anonymous function) @ (index):362
(index):348 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/images/logo.svg 404 (Not Found)
(index):29 GET http://test1.mydomain1.com/static/frontend/Smartwave/porto/sv_SE/css/print.css 

What am I missing ?

0

you need to create sub folders in pub example

pub/website1

it should have index.php with following code

try { require DIR . '/../../app/bootstrap.php'; } catch (\Exception $e) { exit(); }

$params = $_SERVER;

$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website1';

$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

$app = $bootstrap->createApplication('Magento\Framework\App\Http');

$bootstrap->run($app);

and your htaccess in this folder pub/website1 must have

RewriteBase /website1/

I hope this solves your problem. With this you can discard your changes of pub/index.php

| improve this answer | |
0

Actually this solution http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_over.html is correct. The problem was in the ready theme for Magento2 I've bought.. it broke like half of the features. Consider this matter closed.

| improve this answer | |

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.