5

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 'http://127.0.0.1:8080/first_store':
        $mageRunCode = 'base';
        $mageRunType = 'website';
    break;
    case 'http://127.0.0.1:8080/usa':
        $mageRunCode = 'usa_website';
        $mageRunType = 'website';
    break;
}
$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 .*http://127.0.0.1:8080/usa/.* MAGE_RUN_CODE=usa_website
    SetEnvIf Host .*http://127.0.0.1:8080/usa/.* MAGE_RUN_TYPE=website

6) Store configuration,

enter image description here

7) after run 127.0.0.1:8080/usa return 404 error , how can i solve this issue?

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 Jan 4 at 7:57
  • @zus Have you included the store code in URLs from admin config ? – Milind Singh Jan 4 at 8:45
  • Also can you add first_store in apache conf – Milind Singh Jan 4 at 8:47
  • I just want to know how can i add both @Milind Singh – zus Jan 4 at 8:51
  • can you pls join with chat.stackexchange.com/rooms/87829/… @Milind Singh – zus Jan 4 at 9:09
2

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

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.