Max URL Levels in Controller Magento 2












3















I have custom controller outputting JSON format which works well for the below URL level;



** Works
base url/module/folder/action
//equates to VendorModuleControllerFolderIndex.php


However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;



**Hit with 404
base url/module/folder/anotherfolder/action
//equates to VendorModuleControllerFolderAnotherfolderIndex.php

/* or even deeper */

**Hit with 404 - not tested
base url/module/folder/anotherfolder/deeperfolder/action
//equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...



For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)










share|improve this question



























    3















    I have custom controller outputting JSON format which works well for the below URL level;



    ** Works
    base url/module/folder/action
    //equates to VendorModuleControllerFolderIndex.php


    However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;



    **Hit with 404
    base url/module/folder/anotherfolder/action
    //equates to VendorModuleControllerFolderAnotherfolderIndex.php

    /* or even deeper */

    **Hit with 404 - not tested
    base url/module/folder/anotherfolder/deeperfolder/action
    //equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


    I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...



    For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)










    share|improve this question

























      3












      3








      3








      I have custom controller outputting JSON format which works well for the below URL level;



      ** Works
      base url/module/folder/action
      //equates to VendorModuleControllerFolderIndex.php


      However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;



      **Hit with 404
      base url/module/folder/anotherfolder/action
      //equates to VendorModuleControllerFolderAnotherfolderIndex.php

      /* or even deeper */

      **Hit with 404 - not tested
      base url/module/folder/anotherfolder/deeperfolder/action
      //equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


      I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...



      For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)










      share|improve this question














      I have custom controller outputting JSON format which works well for the below URL level;



      ** Works
      base url/module/folder/action
      //equates to VendorModuleControllerFolderIndex.php


      However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;



      **Hit with 404
      base url/module/folder/anotherfolder/action
      //equates to VendorModuleControllerFolderAnotherfolderIndex.php

      /* or even deeper */

      **Hit with 404 - not tested
      base url/module/folder/anotherfolder/deeperfolder/action
      //equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


      I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...



      For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)







      magento2 url controllers






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 15 '18 at 2:09









      BENN1THBENN1TH

      5691516




      5691516






















          2 Answers
          2






          active

          oldest

          votes


















          1














          For this path



          VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


          URL will be



          url/module/folder_anotherfolder_deeperfolder/action


          As per as magento URL format is




          URL/frontenName/ACtionFolder/Action




          Frontendname is defined at routes.xml



          ACtionFolder locates at Controller folder which can multiple folders path but path will connect via (_) Undescore



          Action is the php class.





          share|improve this answer
























          • Yes indeed this is it. thank you +1

            – BENN1TH
            Sep 15 '18 at 6:18











          • ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

            – BENN1TH
            Sep 15 '18 at 6:18





















          0














          In Magento Catalog module has very nice and simple example by adding any product to compare.



          Url Action Is :-



          http://127.0.0.1/magento/catalog/product_compare/index/


          Your Layout is :-



          catalog_product_compare_index.xml


          Folder structure is :-



          /vendor/magento/module-catalog/Controller/Product/Compare/Index.php


          It's very simple, magento has many examples.






          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%2f242362%2fmax-url-levels-in-controller-magento-2%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









            1














            For this path



            VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


            URL will be



            url/module/folder_anotherfolder_deeperfolder/action


            As per as magento URL format is




            URL/frontenName/ACtionFolder/Action




            Frontendname is defined at routes.xml



            ACtionFolder locates at Controller folder which can multiple folders path but path will connect via (_) Undescore



            Action is the php class.





            share|improve this answer
























            • Yes indeed this is it. thank you +1

              – BENN1TH
              Sep 15 '18 at 6:18











            • ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

              – BENN1TH
              Sep 15 '18 at 6:18


















            1














            For this path



            VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


            URL will be



            url/module/folder_anotherfolder_deeperfolder/action


            As per as magento URL format is




            URL/frontenName/ACtionFolder/Action




            Frontendname is defined at routes.xml



            ACtionFolder locates at Controller folder which can multiple folders path but path will connect via (_) Undescore



            Action is the php class.





            share|improve this answer
























            • Yes indeed this is it. thank you +1

              – BENN1TH
              Sep 15 '18 at 6:18











            • ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

              – BENN1TH
              Sep 15 '18 at 6:18
















            1












            1








            1







            For this path



            VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


            URL will be



            url/module/folder_anotherfolder_deeperfolder/action


            As per as magento URL format is




            URL/frontenName/ACtionFolder/Action




            Frontendname is defined at routes.xml



            ACtionFolder locates at Controller folder which can multiple folders path but path will connect via (_) Undescore



            Action is the php class.





            share|improve this answer













            For this path



            VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php


            URL will be



            url/module/folder_anotherfolder_deeperfolder/action


            As per as magento URL format is




            URL/frontenName/ACtionFolder/Action




            Frontendname is defined at routes.xml



            ACtionFolder locates at Controller folder which can multiple folders path but path will connect via (_) Undescore



            Action is the php class.






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 15 '18 at 4:51









            Amit BeraAmit Bera

            57.4k1474171




            57.4k1474171













            • Yes indeed this is it. thank you +1

              – BENN1TH
              Sep 15 '18 at 6:18











            • ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

              – BENN1TH
              Sep 15 '18 at 6:18





















            • Yes indeed this is it. thank you +1

              – BENN1TH
              Sep 15 '18 at 6:18











            • ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

              – BENN1TH
              Sep 15 '18 at 6:18



















            Yes indeed this is it. thank you +1

            – BENN1TH
            Sep 15 '18 at 6:18





            Yes indeed this is it. thank you +1

            – BENN1TH
            Sep 15 '18 at 6:18













            ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

            – BENN1TH
            Sep 15 '18 at 6:18







            ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)

            – BENN1TH
            Sep 15 '18 at 6:18















            0














            In Magento Catalog module has very nice and simple example by adding any product to compare.



            Url Action Is :-



            http://127.0.0.1/magento/catalog/product_compare/index/


            Your Layout is :-



            catalog_product_compare_index.xml


            Folder structure is :-



            /vendor/magento/module-catalog/Controller/Product/Compare/Index.php


            It's very simple, magento has many examples.






            share|improve this answer






























              0














              In Magento Catalog module has very nice and simple example by adding any product to compare.



              Url Action Is :-



              http://127.0.0.1/magento/catalog/product_compare/index/


              Your Layout is :-



              catalog_product_compare_index.xml


              Folder structure is :-



              /vendor/magento/module-catalog/Controller/Product/Compare/Index.php


              It's very simple, magento has many examples.






              share|improve this answer




























                0












                0








                0







                In Magento Catalog module has very nice and simple example by adding any product to compare.



                Url Action Is :-



                http://127.0.0.1/magento/catalog/product_compare/index/


                Your Layout is :-



                catalog_product_compare_index.xml


                Folder structure is :-



                /vendor/magento/module-catalog/Controller/Product/Compare/Index.php


                It's very simple, magento has many examples.






                share|improve this answer















                In Magento Catalog module has very nice and simple example by adding any product to compare.



                Url Action Is :-



                http://127.0.0.1/magento/catalog/product_compare/index/


                Your Layout is :-



                catalog_product_compare_index.xml


                Folder structure is :-



                /vendor/magento/module-catalog/Controller/Product/Compare/Index.php


                It's very simple, magento has many examples.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 4 hours ago

























                answered 5 hours ago









                Manish GoswamiManish Goswami

                502314




                502314






























                    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%2f242362%2fmax-url-levels-in-controller-magento-2%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

                    Polycentropodidae

                    Magento 2 Error message: Invalid state change requested

                    Paulmy