更改webroot的默认路径

更改webroot的默认路径

本文介绍了CAKEPHP - 更改webroot的默认路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cakephp的新手,我在设置本地开发服务器时遇到一些问题。我有我的蛋糕安装,位于。但是,当我尝试访问该url,它告诉我dropbox控制器没有设置。如何告诉CakePHP在 my_site 而不是 / localhost / 中启动?

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/?

我已尝试在路由中添加 connect(/ localhost / dropbox / *)它仍然在错误的位置寻找模型。

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

我尝试在app / webroot中编辑index.php,但是所有的例子显示如何以linux格式编写目录而不是windows,所以我不知道如何结构'ROOT'

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'

推荐答案

CakePHP将在子目录中快速工作 - 我有几个蛋糕网站运行 {appname}。

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

Cake在根索引中定义了ROOT目录。 php文件。如果你看看里面你会看到以下行:

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);

因为它从 dirname(__ FILE __)获取ROOT ,它总是指向该文件的位置。

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.

这篇关于CAKEPHP - 更改webroot的默认路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 13:04