I have created the custom module for custom login, but when I open the below link, it's not redirecting properly.


Below is my route file code and path:


<?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="custommodule" frontName="custommodule">
            <module name="Vendor_Custommodule" />

layout file path:


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
        <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">pressroom</argument>
        <referenceContainer name="content">
           <container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container">
                <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/mycusromlogin.phtml">
                    <container name="form.additional.info" as="form_additional_info"/>


namespace Vendor\Custommodule\Controller\Index;
use Magento\Framework\App\Action\Context;
use Magento\Framework\UrlInterface;
use Magento\Framework\App\Action\Action;
class Index extends \Magento\Framework\App\Action\Action
    protected $_resultPageFactory;
    protected $urlInterface;

    public function __construct(Context $context, 
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         UrlInterface $urlInterface,
         \Magento\Customer\Model\Session $session)
        $this->_resultPageFactory = $resultPageFactory;
        $this->urlInterface = $urlInterface;
         $this->_session = $session;
    public function execute()
        $url = $this->urlInterface->getUrl('custommodule/index/index');

        // Create login URL
        $login_url = $this->urlInterface->getUrl('custommodule/index/index', array('referer' => base64_encode($url))
        // Redirect to login URL
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        if(!$this->_session->isLoggedIn()) {  
            //echo $login_url.'<br /> here'; die;
            $resultRedirect = $this->resultRedirectFactory->create();
            return $resultRedirect;
            //echo $login_url; die;
            $resultPage = $this->_resultPageFactory->create();
            return $resultPage;
  • What do you mean by not properly rendered? Not at all or is an exception being generated?
    – ooxi
    Commented Jun 15, 2017 at 7:58
  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error. Commented Jun 15, 2017 at 8:38
  • Sorry I have misread your title as rendered not redirected, shame on me
    – ooxi
    Commented Jun 15, 2017 at 8:41
  • Ok, please see my code what I am doing. I want to add referer key with route URL, so that when user will login they will redirect on same page after the login. Commented Jun 15, 2017 at 8:43
  • Is the login URL really custommodule/index/index? It seams like you are redirecting to yourself? Maybe change the second custommodule/index/index to customer/account/login
    – ooxi
    Commented Jun 15, 2017 at 8:43

1 Answer 1


You should change layout name pressroom_index_index to custommodule_index_index

Not test you but you should try redirect like below

public function execute() {
--- concat ---


--- concat ---
  • Thanks for your answer, I had solved this issue at my end. Commented Jun 19, 2017 at 5:08

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.