cakephp里面的子目录 [英] cakephp inside a subdirectory
问题描述
我有一个cakephp的问题,我找不到一个方法来获取cakephp在一个子目录中工作。我有一个位于 www.example.com
的网页,我想要在 www.example.com/cake $ c上加入cakephp应用程式$ c>。
www.example.com
是一个虚拟主机, cake
是所有蛋糕文件和目录的子目录。
问题是,当我去 www.example.com/cake
时,它请求一个CakeController并且没有加载样式表。
当我转到 www.example.com/cake/users/register
(= UsersController :: register()
)它显示了正确的网站,但没有CSS。
所以我需要两个东西...来获得 www.example.com / cake
显示主页并加载样式表。
你不知道如何实现吗?
提前感谢
您读过此页,并在 /app/webroot/index.php中进行相应更改
?
编辑:
问题是,当我去
www.example.com/cake它请求一个
CakeController,没有样式表
加载。
这似乎表明你的网站根目录(www,htdocs,public_html或其他)中有错误的.htaccess,因为它试图处理请求到CakePHP结构中。
它应不如下
: < IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ $ app / webroot / [L]
RewriteRule(。*)app / webroot / $ 1 [L]
< / IfModule>
为什么你不能让自己的生活容易,把CakePHP放在根目录并移动页面s)驻留在 www.example.com
到app / webroot。这样,它就会按照你想要的方式工作,例如:
www.example.com/staticPage.html
- 显示静态页面。
www.example.com/users
webroot中的文件与在网站的根目录中一样。想想css和javascript文件。
I have a problem with cakephp, I can't find a way to get cakephp working in a subdirectory. I have a webpage that resides at www.example.com
and I want to have cakephp application on www.example.com/cake
. www.example.com
is a virtual host and cake
is it's subdirectory where all of the cake files and directories are stored.
The problem is that when I go to www.example.com/cake
it requests a CakeController and has no stylesheets loaded.
When I go to www.example.com/cake/users/register
(= UsersController::register()
) it shows the right site but again without CSS.
So I need two things...to get www.example.com/cake
to display the home page and to get the stylesheets loadedd.
Don't you know how to achieve that?
Thanks in advance
Did you read this page in the book and make the appropriate changes in /app/webroot/index.php
?
Edit:
The problem is that when I go to www.example.com/cake it requests a CakeController and has no stylesheets loaded.
This seems to indicate that you have the wrong .htaccess in your site's root (www, htdocs ,public_html or whatever) as it's trying to process the request into the CakePHP structure.
It should not look like this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Why don't you make life easy for yourself and put CakePHP in the root and move the page(s) that reside at www.example.com
into app/webroot. That way it'll behave exactly as you want, i.e:
www.example.com/staticPage.html
- displays the static page.
www.example.com/users
- displays the users index
Files in webroot are served exactly as if they were in the site's root. Think of the css and javascript files.
这篇关于cakephp里面的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!