0

I am using magento 2.2.2

My store was working fine till I added store code to urls so I am no longer able to access my website using my website url mystore.com I have to add store code to access

like this mystore.com/en

how to make resolve this problem so when someone put mystore.com goes directly to mystore.com/en

thank You.

0

Create folder with the name of storecode (ex: en) in root directory.

Create .htaccess file write following code inside file :

**../.htaccess**

Create index.php in the storecode directory add following code :

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
try {
    require __DIR__ . '/app/bootstrap.php';
} catch (\Exception $e) {
    echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
    <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
        <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
        Autoload error</h3>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

$params = $_SERVER;

$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'storecode'; //Webite code as same in admin panel

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

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

/** @var \Magento\Framework\App\Http $app */

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

$bootstrap->run($app);

Then run following ssh command : Terminal navigate to storecode directory (for example : cd /var/www/html/magento/en) path depend on different machine : Run following command

ln -s /var/www/html/app/ /var/www/html/storecode/app 

ln -s /var/www/html/lib/ /var/www/html/storecode/lib 

ln -s /var/www/html/pub/ /var/www/html/storecode/pub 

ln -s /var/www/html/var/ /var/www/html/storecode/var 

Change root directory path according to your machine above is example of apache2

Admin Configuration:

  • Thank You for your response, My stotre url is mystore.com/store so my local disrectory will be mystore.com/store/en mystore.com/store/fr etc ... this is what I put in index.php $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'mystore.com/store/en'; – CDzWebDev Jan 25 '18 at 9:07
  • this solution helps you resolve your issue ? – Shashank Gupta Jan 25 '18 at 9:10
  • I am still having issus understanding it please tell me if this is correct in index.php I edited line 23 with this $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'mystore.com/store/en'; ssh commande with this ln -s /var/www/store/app/ /var/www/store/en/app thank You – CDzWebDev Jan 25 '18 at 9:12
  • You just need to add code : $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'en' – Shashank Gupta Jan 25 '18 at 9:18
  • URL need to mentioned in Admin configuration I mentioned in answer . – Shashank Gupta Jan 25 '18 at 9:20

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.