Skip to main content
added 322 characters in body
Source Link
Duncan Wardlaw
  • 115
  • 1
  • 2
  • 14

I'm currently running a Multistore Magento 2 site, I have 4 websites configured, 2 of which have multiple URL's to access the site.

As a case example I have:

domain-a.com www.domain-a.com domain-a.co.uk www.domain-a.co.uk 

all mapped to the correct store run_code and run_type in index.php

When I access the site using domain-a.com or www.domain-a.com I can see the homepage. All other categories/pages also work. This is true for every category/page for domain-a.co.uk with the exception of the homepage.

Accessing the homepage results in the following:

PHP Fatal error: Uncaught TypeError: explode() expects parameter 2 to be string, null given in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php:182 Stack trace: #0 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(182): explode('/', NULL) #1 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(165): Magento\Framework\App\Router\Base->parseRequest(Object(Magento\Framework\App\Request\Http)) #2 /home/customer/www/DOMAIN.co.uk/public_html/generated/code/Magento/Backend/App/Router/Interceptor.php(24): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http)) #3 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/FrontController.php(95): Magento\Backend\App\Router\Interceptor->match(Object(Magento\Framework\App\Request\Http)) #4 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/Interception/Interceptor.php(58): in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php on line 182 

Tracing this error back, I can see the method $this->pathConfig->getDefaultPath() within vendor/magento/framework/App/Router/Base.php is actually returning null for the request, attempts to add fall-back logic to use values like "cms_index_index" result in displaying the admin login for the default store view, so I suspect somewhere that the request being made for the homepage is being misinterpreted.

I've run a complete cache clean, cleaned my cloudflare cache as well and have also re-compiled and rebuilt the static cache, but nothing I try seems to fix the problem.

I've added the following code to the method as a test:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $state = $objectManager->get('Magento\Framework\App\State'); echo $state->getAreaCode(); //frontend or adminhtml or webapi_rest 

Confusingly, the AreaCode returns as "adminhtml"

I'm currently running a Multistore Magento 2 site, I have 4 websites configured, 2 of which have multiple URL's to access the site.

As a case example I have:

domain-a.com www.domain-a.com domain-a.co.uk www.domain-a.co.uk 

all mapped to the correct store run_code and run_type in index.php

When I access the site using domain-a.com or www.domain-a.com I can see the homepage. All other categories/pages also work. This is true for every category/page for domain-a.co.uk with the exception of the homepage.

Accessing the homepage results in the following:

PHP Fatal error: Uncaught TypeError: explode() expects parameter 2 to be string, null given in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php:182 Stack trace: #0 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(182): explode('/', NULL) #1 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(165): Magento\Framework\App\Router\Base->parseRequest(Object(Magento\Framework\App\Request\Http)) #2 /home/customer/www/DOMAIN.co.uk/public_html/generated/code/Magento/Backend/App/Router/Interceptor.php(24): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http)) #3 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/FrontController.php(95): Magento\Backend\App\Router\Interceptor->match(Object(Magento\Framework\App\Request\Http)) #4 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/Interception/Interceptor.php(58): in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php on line 182 

Tracing this error back, I can see the method $this->pathConfig->getDefaultPath() within vendor/magento/framework/App/Router/Base.php is actually returning null for the request, attempts to add fall-back logic to use values like "cms_index_index" result in displaying the admin login for the default store view, so I suspect somewhere that the request being made for the homepage is being misinterpreted.

I've run a complete cache clean, cleaned my cloudflare cache as well and have also re-compiled and rebuilt the static cache, but nothing I try seems to fix the problem.

I'm currently running a Multistore Magento 2 site, I have 4 websites configured, 2 of which have multiple URL's to access the site.

As a case example I have:

domain-a.com www.domain-a.com domain-a.co.uk www.domain-a.co.uk 

all mapped to the correct store run_code and run_type in index.php

When I access the site using domain-a.com or www.domain-a.com I can see the homepage. All other categories/pages also work. This is true for every category/page for domain-a.co.uk with the exception of the homepage.

Accessing the homepage results in the following:

PHP Fatal error: Uncaught TypeError: explode() expects parameter 2 to be string, null given in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php:182 Stack trace: #0 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(182): explode('/', NULL) #1 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(165): Magento\Framework\App\Router\Base->parseRequest(Object(Magento\Framework\App\Request\Http)) #2 /home/customer/www/DOMAIN.co.uk/public_html/generated/code/Magento/Backend/App/Router/Interceptor.php(24): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http)) #3 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/FrontController.php(95): Magento\Backend\App\Router\Interceptor->match(Object(Magento\Framework\App\Request\Http)) #4 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/Interception/Interceptor.php(58): in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php on line 182 

Tracing this error back, I can see the method $this->pathConfig->getDefaultPath() within vendor/magento/framework/App/Router/Base.php is actually returning null for the request, attempts to add fall-back logic to use values like "cms_index_index" result in displaying the admin login for the default store view, so I suspect somewhere that the request being made for the homepage is being misinterpreted.

I've run a complete cache clean, cleaned my cloudflare cache as well and have also re-compiled and rebuilt the static cache, but nothing I try seems to fix the problem.

I've added the following code to the method as a test:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $state = $objectManager->get('Magento\Framework\App\State'); echo $state->getAreaCode(); //frontend or adminhtml or webapi_rest 

Confusingly, the AreaCode returns as "adminhtml"

Source Link
Duncan Wardlaw
  • 115
  • 1
  • 2
  • 14

Homepage routing problem with $this->pathConfig->getDefaultPath()

I'm currently running a Multistore Magento 2 site, I have 4 websites configured, 2 of which have multiple URL's to access the site.

As a case example I have:

domain-a.com www.domain-a.com domain-a.co.uk www.domain-a.co.uk 

all mapped to the correct store run_code and run_type in index.php

When I access the site using domain-a.com or www.domain-a.com I can see the homepage. All other categories/pages also work. This is true for every category/page for domain-a.co.uk with the exception of the homepage.

Accessing the homepage results in the following:

PHP Fatal error: Uncaught TypeError: explode() expects parameter 2 to be string, null given in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php:182 Stack trace: #0 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(182): explode('/', NULL) #1 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php(165): Magento\Framework\App\Router\Base->parseRequest(Object(Magento\Framework\App\Request\Http)) #2 /home/customer/www/DOMAIN.co.uk/public_html/generated/code/Magento/Backend/App/Router/Interceptor.php(24): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http)) #3 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/FrontController.php(95): Magento\Backend\App\Router\Interceptor->match(Object(Magento\Framework\App\Request\Http)) #4 /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/Interception/Interceptor.php(58): in /home/customer/www/DOMAIN.co.uk/public_html/vendor/magento/framework/App/Router/Base.php on line 182 

Tracing this error back, I can see the method $this->pathConfig->getDefaultPath() within vendor/magento/framework/App/Router/Base.php is actually returning null for the request, attempts to add fall-back logic to use values like "cms_index_index" result in displaying the admin login for the default store view, so I suspect somewhere that the request being made for the homepage is being misinterpreted.

I've run a complete cache clean, cleaned my cloudflare cache as well and have also re-compiled and rebuilt the static cache, but nothing I try seems to fix the problem.