I have magento instance running on 8090 port. I have created an another store call store2 I followed all the steps and also change base url and added store code with base url as per this link

My virtual host file is below.

<VirtualHost *:80>


        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


 <VirtualHost *:80>
    DocumentRoot        /var/www/html/
    SetEnv MAGE_RUN_CODE "store2"
    SetEnv MAGE_RUN_TYPE "website"

My index.php is below.


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;
$customstore = array(
    ''=>'store2' // Website, Store or Storeview Code

    $websitecode = $customstore[$_SERVER['HTTP_HOST']];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = isset($websitecode) ? $websitecode : '';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';//use website or store or view 
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');

but my returns 404 error.

1 Answer 1


I would create a new directory for store2 and copy the .htaccess and index.php into that new directory. Then update /store2/index.php to set the website code and update the line require __DIR__ . '/../../app/bootstrap.php'; to go up one directory. This way when you hit it will start at your new directory and index.php file. You can also symlink media, static, errors, etc from your store2 directory back to your /var/html/www media, static, and error directories. I believe you will also need to update your DocumentRoot in your virtual host from your example above.

Also, if you don't have a home page specified for the new store view it will display a 404 as well.

Your Answer

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

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