Cakephp controller not working in hosted server












-1















My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.



This is the setup on my cPanel File Manager of hosted server:



/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php

/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor


I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:



define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);


I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:



require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));


After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:



The requested URL /test/users was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!










share|improve this question























  • Did you upload the .htaccess file that defines the necessary URL rewrite rules?

    – Joni
    Nov 22 '18 at 2:44











  • @Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

    – JAVAnewbie
    Nov 22 '18 at 4:48











  • Has your autoload been updated for the host directory setup?

    – Greg Schmidt
    Nov 22 '18 at 5:04











  • @Greg i didn't change anything from my autoload.php file.

    – JAVAnewbie
    Nov 22 '18 at 5:07
















-1















My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.



This is the setup on my cPanel File Manager of hosted server:



/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php

/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor


I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:



define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);


I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:



require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));


After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:



The requested URL /test/users was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!










share|improve this question























  • Did you upload the .htaccess file that defines the necessary URL rewrite rules?

    – Joni
    Nov 22 '18 at 2:44











  • @Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

    – JAVAnewbie
    Nov 22 '18 at 4:48











  • Has your autoload been updated for the host directory setup?

    – Greg Schmidt
    Nov 22 '18 at 5:04











  • @Greg i didn't change anything from my autoload.php file.

    – JAVAnewbie
    Nov 22 '18 at 5:07














-1












-1








-1








My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.



This is the setup on my cPanel File Manager of hosted server:



/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php

/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor


I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:



define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);


I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:



require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));


After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:



The requested URL /test/users was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!










share|improve this question














My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.



This is the setup on my cPanel File Manager of hosted server:



/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php

/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor


I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:



define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);


I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:



require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));


After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:



The requested URL /test/users was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!







php cakephp cpanel cakephp-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 2:10









JAVAnewbieJAVAnewbie

124




124













  • Did you upload the .htaccess file that defines the necessary URL rewrite rules?

    – Joni
    Nov 22 '18 at 2:44











  • @Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

    – JAVAnewbie
    Nov 22 '18 at 4:48











  • Has your autoload been updated for the host directory setup?

    – Greg Schmidt
    Nov 22 '18 at 5:04











  • @Greg i didn't change anything from my autoload.php file.

    – JAVAnewbie
    Nov 22 '18 at 5:07



















  • Did you upload the .htaccess file that defines the necessary URL rewrite rules?

    – Joni
    Nov 22 '18 at 2:44











  • @Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

    – JAVAnewbie
    Nov 22 '18 at 4:48











  • Has your autoload been updated for the host directory setup?

    – Greg Schmidt
    Nov 22 '18 at 5:04











  • @Greg i didn't change anything from my autoload.php file.

    – JAVAnewbie
    Nov 22 '18 at 5:07

















Did you upload the .htaccess file that defines the necessary URL rewrite rules?

– Joni
Nov 22 '18 at 2:44





Did you upload the .htaccess file that defines the necessary URL rewrite rules?

– Joni
Nov 22 '18 at 2:44













@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

– JAVAnewbie
Nov 22 '18 at 4:48





@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?

– JAVAnewbie
Nov 22 '18 at 4:48













Has your autoload been updated for the host directory setup?

– Greg Schmidt
Nov 22 '18 at 5:04





Has your autoload been updated for the host directory setup?

– Greg Schmidt
Nov 22 '18 at 5:04













@Greg i didn't change anything from my autoload.php file.

– JAVAnewbie
Nov 22 '18 at 5:07





@Greg i didn't change anything from my autoload.php file.

– JAVAnewbie
Nov 22 '18 at 5:07












2 Answers
2






active

oldest

votes


















0














Upload your .htaccess file.



The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.






share|improve this answer































    0














    You should try changing App.base parameter in ./config/app.php like so:



    'App' => [

    // ...
    'base' => '/test',
    // ...

    ]


    See the documentation here.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      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: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2fstackoverflow.com%2fquestions%2f53422964%2fcakephp-controller-not-working-in-hosted-server%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














      Upload your .htaccess file.



      The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.






      share|improve this answer




























        0














        Upload your .htaccess file.



        The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.






        share|improve this answer


























          0












          0








          0







          Upload your .htaccess file.



          The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.






          share|improve this answer













          Upload your .htaccess file.



          The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 13:28









          JoniJoni

          76.3k997150




          76.3k997150

























              0














              You should try changing App.base parameter in ./config/app.php like so:



              'App' => [

              // ...
              'base' => '/test',
              // ...

              ]


              See the documentation here.






              share|improve this answer




























                0














                You should try changing App.base parameter in ./config/app.php like so:



                'App' => [

                // ...
                'base' => '/test',
                // ...

                ]


                See the documentation here.






                share|improve this answer


























                  0












                  0








                  0







                  You should try changing App.base parameter in ./config/app.php like so:



                  'App' => [

                  // ...
                  'base' => '/test',
                  // ...

                  ]


                  See the documentation here.






                  share|improve this answer













                  You should try changing App.base parameter in ./config/app.php like so:



                  'App' => [

                  // ...
                  'base' => '/test',
                  // ...

                  ]


                  See the documentation here.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 22 '18 at 10:57









                  Timur AsalievTimur Asaliev

                  763




                  763






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • 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%2fstackoverflow.com%2fquestions%2f53422964%2fcakephp-controller-not-working-in-hosted-server%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

                      Costa Masnaga

                      Fotorealismo

                      Sidney Franklin