CAKEPHP - Change default path to webroot

后端 未结 2 1176
孤城傲影
孤城傲影 2021-01-06 08:11

I\'m new to cakephp and I\'m having some problems with setting up a local development server. I have my cake install located at http://localhost/dropbox/my_site/. However,

相关标签:
2条回答
  • 2021-01-06 08:48

    This likely doesn't have so much to do with CakePHP as it does with your web server.

    If dropbox is your document root, it should be mapped accordingly in your web server configuration. For example using DocumentRoot in Apache.

    0 讨论(0)
  • 2021-01-06 08:50

    CakePHP will work happily in a subdirectory - I have several Cake sites running at http://localhost/{appname} on my dev machine.

    Cake defines its ROOT directory in the root index.php file. If you look inside you'll see the following lines:

    define('ROOT', dirname(__FILE__));
    define('WEBROOT_DIR', 'webroot');
    define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
    

    Since it's taking ROOT from dirname(__FILE__), it will always point to that file's location.

    I suspect you have problems in your routing file. Did you create any custom routing rules to account for being located in a subdirectory? If you did, your cake install may be trying to access http://localhost/dropbox/my_site/dropbox/... and that's why you're getting that error.

    0 讨论(0)
提交回复
热议问题