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

                              Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                              Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form