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 Jun 15 '17 at 7:58
  • It's not redirecting properly. it's showing the The page isn’t redirecting properly error. – mageDev0688 Jun 15 '17 at 8:38
  • Sorry I have misread your title as rendered not redirected, shame on me – ooxi Jun 15 '17 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. – mageDev0688 Jun 15 '17 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 Jun 15 '17 at 8:43

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 ---
| improve this answer | |
  • Thanks for your answer, I had solved this issue at my end. – mageDev0688 Jun 19 '17 at 5:08

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.