I am creating a shop with only one product. I want this product page to be the homepage, or instantly redirect to that product page when i visit the store. Any idea how?

I did find this option to set a homepage url:

enter image description here

But if i simply enter


there then it won't work and my homepage returns a 404.


I ended up creating a module and using the following code:


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch">
    <observer name="controller_action_predispatch" instance="BB\BB\Observer\ControllerPredispatch" />



namespace BB\BB\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;

class ControllerPredispatch implements ObserverInterface
     * @var \Magento\Framework\UrlInterface
    protected $url;

     * @var \Magento\Framework\App\Response\Http
    protected $http;

    /** @var \Magento\Customer\Model\Session */
    protected $customerSession;

     * @param \Magento\Framework\UrlInterface $url
     * @param \Magento\Framework\App\Response\Http $http
     * @param \Magento\Customer\Model\Session $customerSession
    public function __construct(
        \Magento\Framework\UrlInterface $url,
        \Magento\Framework\App\Response\Http $http,
        \Magento\Customer\Model\Session $customerSession
        $this->url = $url;
        $this->http = $http;
        $this->customerSession = $customerSession;

     * Manages redirect
    public function execute(Observer $observer)
         * Check if user logged in
        if ($this->customerSession->isLoggedIn()) {

        if ($observer->getRequest()->getFullActionName() == 'cms_index_index') {
             * Redirect to login
            $this->http->setRedirect($this->url->getUrl('bb-check-extension.html'), 301);

Code is created by SR: Magento 2 : Redirect From Homepage to Login if not Logged


There is actually an easier way, in the default web url put:


Where "1" is the id of your product you want to show. I have tested it and it's working.

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.