Workout :

1) Created new folder in Root folder named usa,

2) Copy index.php and .htaccess from root folder and moved to usa folder

3) Created symbolic links to usa folder, usa symbolic links are,

C:\wamp\www\first_store>mklink /d ..\first_store\usa\app.\app
C:\wamp\www\first_store>mklink /d ..\first_store\usa\pub.\pub
C:\wamp\www\first_store>mklink /d ..\first_store\usa\lib.\lib
C:\wamp\www\first_store>mklink /d ..\first_store\usa\var.\var

4)usa index.php,

Set values for the MAGE_RUN_TYPE and MAGE_RUN_CODE

Open the index.php file under application root directory

Replacing this code: $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

by these codes: 

switch($_SERVER['HTTP_HOST']) {
    case '':
        $mageRunCode = 'base';
        $mageRunType = 'website';
    case '':
        $mageRunCode = 'usa_website';
        $mageRunType = 'website';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $mageRunCode;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = $mageRunType;
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

5) usa .htaccess file,

## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

    SetEnvIf Host .** MAGE_RUN_CODE=usa_website
    SetEnvIf Host .** MAGE_RUN_TYPE=website

6) Store configuration,

enter image description here

7) after run return 404 error , how can i solve this issue?

3 Answers 3

  1. Check that you have enabled To include the store code in URLs as explained in user guide here.
  2. Try to either the .htaccess or index.php override. So you can remove, $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $mageRunCode; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = $mageRunType;

  • After remove $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $mageRunCode; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = $mageRunType; still getting same error @Milind Singh
    – zus
    Commented Jan 4, 2019 at 7:57
  • @zus Have you included the store code in URLs from admin config ? Commented Jan 4, 2019 at 8:45
  • Also can you add first_store in apache conf Commented Jan 4, 2019 at 8:47
  • I just want to know how can i add both @Milind Singh
    – zus
    Commented Jan 4, 2019 at 8:51
  • can you pls join with chat.stackexchange.com/rooms/87829/… @Milind Singh
    – zus
    Commented Jan 4, 2019 at 9:09

You need to set the Base URL for the store view in the admin. I had the same issue until I did that.


I have setup 2 websites using below steps: (nothing extra)

  1. Provide store urls in admin on website level

    Stores > Configuration > General > Web > Base Urls

  2. Update .htaccess file same as you did in step 5 just exclude protocol and add those lines above RewriteEnging on line

  3. Update virtual host entry

  4. Restart apache

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.