0

I had two websites in magento 2 and I deleted one but it gave me error that

The website with code root that was requested wasn't found. Verify the website and try again

Now, I am unable to view the admin panel. What should I do? Thanks in advance.

2
  • Can you please check your index.php file which is available on Magento ROOT. Is there any keyword such as root for website code ? Commented Nov 4, 2019 at 10:13
  • yes there is root in PARAM_RUN_CODE = 'root'
    – user84050
    Commented Nov 4, 2019 at 10:17

1 Answer 1

1

You need to update your index.php file with you website code like this

<?php
/**
 * Application entry point
 *
 * Example - run a particular store or website:
 * --------------------------------------------
 * require __DIR__ . '/app/bootstrap.php';
 * $params = $_SERVER;
 * $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2';
 * $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::class);
 * $bootstrap->run($app);
 * --------------------------------------------
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

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>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

switch ($_SERVER['HTTP_HOST']) {
    case 'first.websiteurl.com': // Your first website URL
        $params = $_SERVER; 
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website_code1'; //You can add your first website code here
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; 
        $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); 
        $app = $bootstrap->createApplication('Magento\Framework\App\Http'); 
        $bootstrap->run($app); 
        break; 
    case 'second.websiteurl.com': // Your second website URL
        $params = $_SERVER; 
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website_code2'; //You can add your second website code here
        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; 
        $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); 
        $app = $bootstrap->createApplication('Magento\Framework\App\Http'); 
        $bootstrap->run($app); 
        break;
    default: 
        $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
        $app = $bootstrap->createApplication('Magento\Framework\App\Http');
        $bootstrap->run($app);
    break; 
}

You can find you website code here in backend..

Stores > Settings > All Stores

Default index.php file's content..

<?php
/**
 * Application entry point
 *
 * Example - run a particular store or website:
 * --------------------------------------------
 * require __DIR__ . '/app/bootstrap.php';
 * $params = $_SERVER;
 * $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website2';
 * $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::class);
 * $bootstrap->run($app);
 * --------------------------------------------
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

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>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$bootstrap->run($app);

Hope this will help you!

11
  • Let me know if this will helps you then. Commented Nov 4, 2019 at 10:23
  • I am unable to access my admin panel.
    – user84050
    Commented Nov 4, 2019 at 10:42
  • You can comment these both lines.. $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website_code1'; //You can add your first website code here $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; Commented Nov 4, 2019 at 10:44
  • After commenting there is another error Warning: Cannot modify header information - headers already sent by (output started at \/var\/www\/html\/Magento2\/vendor\/zendframework\/zend-http\/src\/PhpEnvironment\/Response.php:114) in \/var\/www\/html\/Magento2\/vendor\/magento\/framework\/Stdlib\/Cookie\/PhpCookieManager.php on line 148"
    – user84050
    Commented Nov 4, 2019 at 10:48
  • 1
    Thank you it worked.
    – user84050
    Commented Nov 4, 2019 at 11:17

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.