dtds8802 2012-02-28 16:41
浏览 103
已采纳

CAKEPHP - 将默认路径更改为webroot

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, when I try to visit that url, it tells me the dropbox controller isn't set up. How do I tell CakePHP to start in my_site rather than /localhost/?

I've tried adding connect(/localhost/dropbox/*) to the routes, but it seems like it still looks for models in the wrong location.

I tried editing index.php in app/webroot but all the examples show how to write the directory in linux format rather than windows, so I'm not sure how to structure 'ROOT'

  • 写回答

2条回答 默认 最新

  • douqian3712 2012-02-28 16:52
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算