在一个子目录中安装CakePHP的2.0.0 [英] installing cakephp 2.0.0 in a subdirectory

查看:94
本文介绍了在一个子目录中安装CakePHP的2.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个类似的问题这里但没有找到一个解决方案。基本上我已经安装在一个子目录本地主机/ dyod现有的CakePHP应用程序。而不编辑htaccess的文件,我得到一个错误,告诉我​​该应用程序正在寻找dyod控制器,因此看似URI是关闭莫名其妙。当我一个的RewriteBase添加到htaccess的文件(/ dyod /),那么所有的资产网址的关闭,不包括根目录。同时,它仍然是寻找dyod控制器。我的htaccess的文件从这里复制。

i found a similar problem here but did not find a solution. basically i have installed an existing cakephp application in a subdirectory 'localhost/dyod'. without editing the htaccess files, i get an error telling me that the app is looking for the dyod controller, so seemingly the uri is off somehow. when i add a rewritebase to the htaccess files (/dyod/) then all the assets' urls are off and don't include the webroot. also, it is still looking for a dyod controller. my htaccess files are copied from here.

先谢谢了。

推荐答案

添加到这一点,因为这是在我的谷歌搜索的顶部,这些答案没有帮助。

Adding on to this since it was at the top of my google search and these answers didn't help.

CakePHP的使用,所有需要修改3 .htaccess文件。一个在顶部CakePHP的目录,一个在应用程序/和一个在app / webroot的。以下内容添加到每个这些:

CakePHP uses 3 .htaccess files that all need modifying. One in the top CakePHP dir, one in app/ and one in app/webroot. Add the following to each of these:

的RewriteBase /路径/要/ DIR /

RewriteBase /path/to/dir/

在我的机器上,我有以下结构:
〜/网站/ site1的
〜/网站/站点2 /管理员

On my machine I have the following structure: ~/Sites/site1 ~/sites/site2/admin

每个这些目录中有一个单独的安装CakePHP的的。

Each of those directories have a seperate install of CakePHP.

通过安装在站点1和站点2 /管理CakePHP的。
这些网站的网址是:

With CakePHP installed in site1 and in site2/admin. The urls for these sites are:

http://localhost/~me/site1
http://localhost/~me/site2/admin

我不断收到此错误:
所请求的URL /home/me/Sites/site1/app/webroot/index.php没有在此服务器上找到。

I kept getting this error: The requested URL /home/me/Sites/site1/app/webroot/index.php was not found on this server.

我修改了3 .htaccess文件来获得这些:

I modified the 3 .htaccess files to get these:

site1 .htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /~me/site1/
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

site1/app .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /~me/site1/app/
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

site1/app/webroot .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~me/site1/app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

就是这样。这三个变化是你所需要的。

That's it. Those three changes are all you need.

这篇关于在一个子目录中安装CakePHP的2.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆