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.

1 Answer 1


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

Create .htaccess file write following code inside file :


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

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>

$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');


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';
    – SoCix
    Jan 25, 2018 at 9:07
  • this solution helps you resolve your issue ? Jan 25, 2018 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
    – SoCix
    Jan 25, 2018 at 9:12
  • You just need to add code : $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'en' Jan 25, 2018 at 9:18
  • URL need to mentioned in Admin configuration I mentioned in answer . Jan 25, 2018 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.