Magento – Magento 2.3.0 – Multi Website Store URL Return 404 error

localhostmagento2.3multi-websitewamp

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?

Best Answer

  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;

Related Topic