I want to change default home page to login page in Magento 2.3

Mean that want to see customer login instead of homepage

1 Answer 1


Reference Link

Create Event controller_action_predispatch, we can follow:


 <event name="controller_action_predispatch">
        <observer name="check_login_persistent" instance="Vendor\Module\Observer\CheckLoginPersistentObserver" />


     * @var \Magento\Framework\App\Response\RedirectInterface
    protected $redirect;

     * Customer session
     * @var \Magento\Customer\Model\Session
    protected $_customerSession;

    public function __construct(
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Framework\App\Response\RedirectInterface $redirect

    ) {

        $this->_customerSession = $customerSession;
        $this->redirect = $redirect;


    public function execute(\Magento\Framework\Event\Observer $observer)
        $actionName = $observer->getEvent()->getRequest()->getFullActionName();
        $controller = $observer->getControllerAction();

        $openActions = array(
        if ($controller == 'account' && in_array($actionName, $openActions)) {
            return $this; //if in allowed actions do nothing.
        if(!$this->_customerSession->isLoggedIn()) {
            $this->redirect->redirect($controller->getResponse(), 'customer/account/login');


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.