Difference between root index.php and pub directory index.php in Magento2?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





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







up vote
3
down vote

favorite
2












Can any one tell me the logical difference between of using index.php in root directory and pub directory when we go live to point domain then which index.php should be pointed by domain?










share|improve this question



























    up vote
    3
    down vote

    favorite
    2












    Can any one tell me the logical difference between of using index.php in root directory and pub directory when we go live to point domain then which index.php should be pointed by domain?










    share|improve this question























      up vote
      3
      down vote

      favorite
      2









      up vote
      3
      down vote

      favorite
      2






      2





      Can any one tell me the logical difference between of using index.php in root directory and pub directory when we go live to point domain then which index.php should be pointed by domain?










      share|improve this question













      Can any one tell me the logical difference between of using index.php in root directory and pub directory when we go live to point domain then which index.php should be pointed by domain?







      magento2 domain






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      Charul Tyagi

      41710




      41710




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote













          Magento2 uses the /index.php is mainly for the CLI commands where there is no use of media and static folders. But while you access the website, you need to point to the index.php only. Because the media paths were defined only in pub/index.php.






          share|improve this answer



























            up vote
            2
            down vote













            Magento 2 generally use /index.php in root file. But when you will go live and change the mode to production Magento will use pub/index.php.






            share|improve this answer



























              up vote
              1
              down vote













              In magento 2 root/index.php and pub/index.php both index.php are entry points and they are reusing the same app/bootstrap.php



              • The pub/index.php -- if you are able to configure the "pub" directory as the document root on Server.

              • In order to run a Magento 2 web application, the "pub" directory is the only one that's necessary to expose.

              • The rest you can hide (typically for security reasons, to avoid accidental exposing local.xml or something like that).

              • It is more secure than root.

              Hint : https://github.com/magento/magento2/issues/356






              share|improve this answer




















              • If our folder permissions are right then what security can be leaked due to using root index.php?
                – Charul Tyagi
                19 mins ago










              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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              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%2f243015%2fdifference-between-root-index-php-and-pub-directory-index-php-in-magento2%23new-answer', 'question_page');

              );

              Post as a guest






























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              Magento2 uses the /index.php is mainly for the CLI commands where there is no use of media and static folders. But while you access the website, you need to point to the index.php only. Because the media paths were defined only in pub/index.php.






              share|improve this answer
























                up vote
                2
                down vote













                Magento2 uses the /index.php is mainly for the CLI commands where there is no use of media and static folders. But while you access the website, you need to point to the index.php only. Because the media paths were defined only in pub/index.php.






                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  Magento2 uses the /index.php is mainly for the CLI commands where there is no use of media and static folders. But while you access the website, you need to point to the index.php only. Because the media paths were defined only in pub/index.php.






                  share|improve this answer












                  Magento2 uses the /index.php is mainly for the CLI commands where there is no use of media and static folders. But while you access the website, you need to point to the index.php only. Because the media paths were defined only in pub/index.php.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Pavan Kumar

                  3221211




                  3221211






















                      up vote
                      2
                      down vote













                      Magento 2 generally use /index.php in root file. But when you will go live and change the mode to production Magento will use pub/index.php.






                      share|improve this answer
























                        up vote
                        2
                        down vote













                        Magento 2 generally use /index.php in root file. But when you will go live and change the mode to production Magento will use pub/index.php.






                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          Magento 2 generally use /index.php in root file. But when you will go live and change the mode to production Magento will use pub/index.php.






                          share|improve this answer












                          Magento 2 generally use /index.php in root file. But when you will go live and change the mode to production Magento will use pub/index.php.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 1 hour ago









                          Aniket Prajapati

                          287




                          287




















                              up vote
                              1
                              down vote













                              In magento 2 root/index.php and pub/index.php both index.php are entry points and they are reusing the same app/bootstrap.php



                              • The pub/index.php -- if you are able to configure the "pub" directory as the document root on Server.

                              • In order to run a Magento 2 web application, the "pub" directory is the only one that's necessary to expose.

                              • The rest you can hide (typically for security reasons, to avoid accidental exposing local.xml or something like that).

                              • It is more secure than root.

                              Hint : https://github.com/magento/magento2/issues/356






                              share|improve this answer




















                              • If our folder permissions are right then what security can be leaked due to using root index.php?
                                – Charul Tyagi
                                19 mins ago














                              up vote
                              1
                              down vote













                              In magento 2 root/index.php and pub/index.php both index.php are entry points and they are reusing the same app/bootstrap.php



                              • The pub/index.php -- if you are able to configure the "pub" directory as the document root on Server.

                              • In order to run a Magento 2 web application, the "pub" directory is the only one that's necessary to expose.

                              • The rest you can hide (typically for security reasons, to avoid accidental exposing local.xml or something like that).

                              • It is more secure than root.

                              Hint : https://github.com/magento/magento2/issues/356






                              share|improve this answer




















                              • If our folder permissions are right then what security can be leaked due to using root index.php?
                                – Charul Tyagi
                                19 mins ago












                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote









                              In magento 2 root/index.php and pub/index.php both index.php are entry points and they are reusing the same app/bootstrap.php



                              • The pub/index.php -- if you are able to configure the "pub" directory as the document root on Server.

                              • In order to run a Magento 2 web application, the "pub" directory is the only one that's necessary to expose.

                              • The rest you can hide (typically for security reasons, to avoid accidental exposing local.xml or something like that).

                              • It is more secure than root.

                              Hint : https://github.com/magento/magento2/issues/356






                              share|improve this answer












                              In magento 2 root/index.php and pub/index.php both index.php are entry points and they are reusing the same app/bootstrap.php



                              • The pub/index.php -- if you are able to configure the "pub" directory as the document root on Server.

                              • In order to run a Magento 2 web application, the "pub" directory is the only one that's necessary to expose.

                              • The rest you can hide (typically for security reasons, to avoid accidental exposing local.xml or something like that).

                              • It is more secure than root.

                              Hint : https://github.com/magento/magento2/issues/356







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 24 mins ago









                              Pradeep Thakur

                              393




                              393











                              • If our folder permissions are right then what security can be leaked due to using root index.php?
                                – Charul Tyagi
                                19 mins ago
















                              • If our folder permissions are right then what security can be leaked due to using root index.php?
                                – Charul Tyagi
                                19 mins ago















                              If our folder permissions are right then what security can be leaked due to using root index.php?
                              – Charul Tyagi
                              19 mins ago




                              If our folder permissions are right then what security can be leaked due to using root index.php?
                              – Charul Tyagi
                              19 mins ago

















                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f243015%2fdifference-between-root-index-php-and-pub-directory-index-php-in-magento2%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              How to decode/decipher Mozilla Firefox proprietary .jsonlz4 format? (sessionstore-backups/recovery.jsonlz4)

                              White Anglo-Saxon Protestant

                              How to be valuable when automation & IT are stealing my job (and maybe my whole career)? [closed]