2

I am working on Magento ver. 2.1.7 and my document root is /var/www/magento2/ and site URL http://172.16.60.52/magento2/

In the admin menu Stores -> Settings -> All Store I have created One Main Website and two store for Electronic and Fashion . Also I have created store view for each store having code electronic and fashion respectively.

In the admin section I have set the following configurations

Stores - > Settings -> Configuration -> General -> Web -> (Store View: Default Config) Add Store Code to Urls - > Yes

Stores - > Settings -> Configuration -> General -> Web -> (Store View: Electronic)

Base URL -> http://172.16.60.52/magento2/electronic/

Base Link URL -> http://172.16.60.52/magento2/electronic/

Secure Base URL -> http://172.16.60.52/magento2/electronic/

Secure Base Link URL -> http://172.16.60.52/magento2/electronic/

Stores - > Settings -> Configuration -> General -> Web -> (Store View: Fashion)

Base URL -> http://172.16.60.52/magento2/fashion/

Base Link URL -> http://172.16.60.52/magento2/fashion/

Secure Base URL -> http://172.16.60.52/magento2/fashion/

Secure Base Link URL -> http://172.16.60.52/magento2/fashion/

I have created two directories electronic & fashion in document root, copied index.php and .htaccess files from magento2 directory to electronic and fashion directory

I have change the /var/www/magento2/electronic/index.php file as code given below...

$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'electronic';
$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);

Also, I have change the /var/www/magento2/fashion/index.php file as code given below...

$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'fashion';
$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);

While accessing url http://172.16.60.52/magento2/electronic/ we got the following error

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 876098939040

Log file info :

a:4:{i:0;s:15:"No such entity.";i:1;s:4915:"#0 /var/www/magento/ehgsdigi/vendor/magento/module-store/Model/StoreResolver/Website.php(46): Magento\Store\Model\WebsiteRepository->get('electronic')

...................

Please advice me

0

Well I've done in another way maybe you are interested...

I've not edited any index.php or .htaccess file.

I've edited virtual host as below.

My default website :

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName main-shop.local
  DocumentRoot /home/mypc/Projects/main-shop

  ErrorLog /home/mypc/Projects/main-shop/error.log
  CustomLog /home/mypc/Projects/main-shop/access.log combined

  <Directory />
        Options FollowSymLinks
    AllowOverride None
    </Directory>

    <Directory /home/mypc/Projects/main-shop>
        Require all granted
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride All
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

My another website:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName main-shop-test.local
  DocumentRoot /home/mypc/Projects/main-shop/pub
    SetEnv MAGE_RUN_CODE "f2f89c0ef1_146f0ca8f6"
    SetEnv MAGE_RUN_TYPE "website"

  ErrorLog /home/mypc/Projects/main-shop/error.log
  CustomLog /home/mypc/Projects/main-shop/access.log combined

  <Directory />
        Options FollowSymLinks
    AllowOverride None
    </Directory>

    <Directory /home/mypc/Projects/main-shop/pub>
        Require all granted
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride All
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

In above virtual host I've added my website code and rest magento will do by itself.

  • Is there any other solution? Instead of modifying virtual host. – Kishor Hase Jun 22 '17 at 11:54

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.