Magento 2 : How to forward controller defaultNoRoute?Magento 2 Create custom 404 page for not-found productsStatus 200 for 404 Not Found CMS page404 - Redirect to Home Page - Banner Slider Not WorkingMagento 404 errors are showing the standard apache 404 error instead of custom Magento 404404 on startup page changing admin panel URLHow to forward all the 404 Magento pages to the front page?URL Rewrite and 301 Permission not working properly404 Not Found 1 when view product detail page after customer loggingFrontend layout not working after upgrading to Magento 2.1How to redirect 404 error to specific url?Magento 2 : custom no-route url in nginx server

Parsing text written the millitext font

Is Jesus the last Prophet?

Is the first of the 10 Commandments considered a mitzvah?

Why is my Taiyaki (Cake that looks like a fish) too hard and dry?

Am I being scammed by a sugar daddy?

Does WiFi affect the quality of images downloaded from the internet?

Can I attach a DC blower to intake manifold of my 150CC Yamaha FZS FI engine?

Fully extended TQFT and lattice models

Is it true that "only photographers care about noise"?

How (un)safe is it to ride barefoot?

How do I properly use a function under a class?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

My mom's return ticket is 3 days after I-94 expires

Why does there seem to be an extreme lack of public trashcans in Taiwan?

As easy as Three, Two, One... How fast can you go from Five to Four?

Nth term of Van Eck Sequence

Did I need a visa in 2004 and 2006?

Undocumented incompatibility between changes and siunitx?

Which are the methodologies for interpreting Vedas?

Is it good practice to create tables dynamically?

I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?

What is the theme of analysis?

What did the 8086 (and 8088) do upon encountering an illegal instruction?

Why did the AvroCar fail to fly above 3 feet?



Magento 2 : How to forward controller defaultNoRoute?


Magento 2 Create custom 404 page for not-found productsStatus 200 for 404 Not Found CMS page404 - Redirect to Home Page - Banner Slider Not WorkingMagento 404 errors are showing the standard apache 404 error instead of custom Magento 404404 on startup page changing admin panel URLHow to forward all the 404 Magento pages to the front page?URL Rewrite and 301 Permission not working properly404 Not Found 1 when view product detail page after customer loggingFrontend layout not working after upgrading to Magento 2.1How to redirect 404 error to specific url?Magento 2 : custom no-route url in nginx server






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I create a custom module in which if data is found the template is shown else I need to show default 404-page content & set the status to 404.



I have tried below code to set the status to 404 without changing the URL(i.e, not redirecting to noroute)



$resultPage->setStatusHeader(404, '1.1', 'Page Not Found');
$resultPage->setHeader('Status', '404 Page Not Found');


But I'm unable to show the default 404 error page content.



I have tried below code to forward the controller to default no route page, but it's not working for me.



$this->_forward('defaultNoRoute');


Can anyone help me out from this? Thanks in advance.










share|improve this question




























    0















    I create a custom module in which if data is found the template is shown else I need to show default 404-page content & set the status to 404.



    I have tried below code to set the status to 404 without changing the URL(i.e, not redirecting to noroute)



    $resultPage->setStatusHeader(404, '1.1', 'Page Not Found');
    $resultPage->setHeader('Status', '404 Page Not Found');


    But I'm unable to show the default 404 error page content.



    I have tried below code to forward the controller to default no route page, but it's not working for me.



    $this->_forward('defaultNoRoute');


    Can anyone help me out from this? Thanks in advance.










    share|improve this question
























      0












      0








      0








      I create a custom module in which if data is found the template is shown else I need to show default 404-page content & set the status to 404.



      I have tried below code to set the status to 404 without changing the URL(i.e, not redirecting to noroute)



      $resultPage->setStatusHeader(404, '1.1', 'Page Not Found');
      $resultPage->setHeader('Status', '404 Page Not Found');


      But I'm unable to show the default 404 error page content.



      I have tried below code to forward the controller to default no route page, but it's not working for me.



      $this->_forward('defaultNoRoute');


      Can anyone help me out from this? Thanks in advance.










      share|improve this question














      I create a custom module in which if data is found the template is shown else I need to show default 404-page content & set the status to 404.



      I have tried below code to set the status to 404 without changing the URL(i.e, not redirecting to noroute)



      $resultPage->setStatusHeader(404, '1.1', 'Page Not Found');
      $resultPage->setHeader('Status', '404 Page Not Found');


      But I'm unable to show the default 404 error page content.



      I have tried below code to forward the controller to default no route page, but it's not working for me.



      $this->_forward('defaultNoRoute');


      Can anyone help me out from this? Thanks in advance.







      magento2 404-page 404 noroute






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 6 at 10:18









      Mandar ParbateMandar Parbate

      302623




      302623




















          2 Answers
          2






          active

          oldest

          votes


















          0














          You Can Override MagentoFrameworkAppRouterNoRouteHandlerList File In app/code/Vendor/Module/etc/frontend/di.xml



          And You Can Add Your Code Like This :-



          public function execute()

          $resultLayout = $this->resultPageFactory->create();
          $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
          $resultLayout->setHeader('Status', '404 File not found');
          return $resultLayout;



          Reference Link



          Create custom 404 page for not-found products






          share|improve this answer






























            0














            Use this class for redirection



            public function __construct
            (
            MagentoFrameworkControllerResultForwardFactory $forwardFactory
            )

            $this->_forwardFactory = $forwardFactory;



            Now you can redirect to 404 page using this



            if(CONDITION)

            $resultForward = $this->_forwardFactory->create();
            $resultForward->setController('index');
            $resultForward->forward('defaultNoRoute');
            return $resultForward;






            share|improve this answer























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277459%2fmagento-2-how-to-forward-controller-defaultnoroute%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              You Can Override MagentoFrameworkAppRouterNoRouteHandlerList File In app/code/Vendor/Module/etc/frontend/di.xml



              And You Can Add Your Code Like This :-



              public function execute()

              $resultLayout = $this->resultPageFactory->create();
              $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
              $resultLayout->setHeader('Status', '404 File not found');
              return $resultLayout;



              Reference Link



              Create custom 404 page for not-found products






              share|improve this answer



























                0














                You Can Override MagentoFrameworkAppRouterNoRouteHandlerList File In app/code/Vendor/Module/etc/frontend/di.xml



                And You Can Add Your Code Like This :-



                public function execute()

                $resultLayout = $this->resultPageFactory->create();
                $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
                $resultLayout->setHeader('Status', '404 File not found');
                return $resultLayout;



                Reference Link



                Create custom 404 page for not-found products






                share|improve this answer

























                  0












                  0








                  0







                  You Can Override MagentoFrameworkAppRouterNoRouteHandlerList File In app/code/Vendor/Module/etc/frontend/di.xml



                  And You Can Add Your Code Like This :-



                  public function execute()

                  $resultLayout = $this->resultPageFactory->create();
                  $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
                  $resultLayout->setHeader('Status', '404 File not found');
                  return $resultLayout;



                  Reference Link



                  Create custom 404 page for not-found products






                  share|improve this answer













                  You Can Override MagentoFrameworkAppRouterNoRouteHandlerList File In app/code/Vendor/Module/etc/frontend/di.xml



                  And You Can Add Your Code Like This :-



                  public function execute()

                  $resultLayout = $this->resultPageFactory->create();
                  $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
                  $resultLayout->setHeader('Status', '404 File not found');
                  return $resultLayout;



                  Reference Link



                  Create custom 404 page for not-found products







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 6 at 11:09









                  Rk RathodRk Rathod

                  2,261315




                  2,261315























                      0














                      Use this class for redirection



                      public function __construct
                      (
                      MagentoFrameworkControllerResultForwardFactory $forwardFactory
                      )

                      $this->_forwardFactory = $forwardFactory;



                      Now you can redirect to 404 page using this



                      if(CONDITION)

                      $resultForward = $this->_forwardFactory->create();
                      $resultForward->setController('index');
                      $resultForward->forward('defaultNoRoute');
                      return $resultForward;






                      share|improve this answer



























                        0














                        Use this class for redirection



                        public function __construct
                        (
                        MagentoFrameworkControllerResultForwardFactory $forwardFactory
                        )

                        $this->_forwardFactory = $forwardFactory;



                        Now you can redirect to 404 page using this



                        if(CONDITION)

                        $resultForward = $this->_forwardFactory->create();
                        $resultForward->setController('index');
                        $resultForward->forward('defaultNoRoute');
                        return $resultForward;






                        share|improve this answer

























                          0












                          0








                          0







                          Use this class for redirection



                          public function __construct
                          (
                          MagentoFrameworkControllerResultForwardFactory $forwardFactory
                          )

                          $this->_forwardFactory = $forwardFactory;



                          Now you can redirect to 404 page using this



                          if(CONDITION)

                          $resultForward = $this->_forwardFactory->create();
                          $resultForward->setController('index');
                          $resultForward->forward('defaultNoRoute');
                          return $resultForward;






                          share|improve this answer













                          Use this class for redirection



                          public function __construct
                          (
                          MagentoFrameworkControllerResultForwardFactory $forwardFactory
                          )

                          $this->_forwardFactory = $forwardFactory;



                          Now you can redirect to 404 page using this



                          if(CONDITION)

                          $resultForward = $this->_forwardFactory->create();
                          $resultForward->setController('index');
                          $resultForward->forward('defaultNoRoute');
                          return $resultForward;







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 6 at 11:44









                          user4536user4536

                          15313




                          15313



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277459%2fmagento-2-how-to-forward-controller-defaultnoroute%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                              Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                              Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?