Cakephp不加载css和js文件 [英] Cakephp not loading css and js files
问题描述
我真的不明白这里发生了什么。我刚刚将Web应用程序从localhost上传到Windows IIS Server上的新域名。当我尝试访问Web应用程序时,未加载CSS文件和图像,并且出现以下错误:
I seriously can't understand what is going on here. I just uploaded my web app from localhost to new domain-name on Windows IIS Server. When I try to access the web app, CSS files and images are not loaded and I get the following error:
CssController 找到。
我不明白为什么这样做。
尽管我已经在default.ctp中编写了这样的代码:
I don't understand why it is doing this. Although I've written code like this in my default.ctp:
echo $this->html->css('generic');
CSS文件位于:
app\webroot\css
我在Google上搜索过并尝试了一切,我什至没有注释以下行:
I have searched on Google and have tried everything, I even uncommented the line:
Configure::write('App.baseUrl',env('SCRIPT_NAME')); in core.php
中,但我仍然无法使它正常工作。请帮助我解决此问题。
But I still cannot get this to work. Please help me to resolve this issue.
推荐答案
再次检查是否已安装所有.htaccess文件。
还应确保/ app / webroot /具有其.htaccess文件:
Double check that you have all the .htaccess files in place. Also making sure /app/webroot/ has its .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
您的请求试图从/ css /获取css文件,但我认为您没有不要放置适当的.htaccess文件以将其路由到webroot而不是控制器!
Your request is trying to get the css file from /css/ but i'm thinking you don't have the proper .htaccess files in place to route it to the webroot and not to a controller!
还要检查是否启用了mod_rewrite
also check if mod_rewrite is enabled
编辑:然后我看到了IIS部分,您需要一些IIS等效于mod_rewrite
and then I saw the IIS part, you need some IIS equivalent to mod_rewrite
在本文中,您将找到在Microsoft IIS Web服务器下成功运行CakePHP Web应用程序所需的所有信息: http://bakery.cakephp.org/articles/filippo.toso/2008/01/29 / cakephp-on-iis
In this article you find all the information required for successfully run CakePHP web applications under Microsoft IIS web server: http://bakery.cakephp.org/articles/filippo.toso/2008/01/29/cakephp-on-iis
以下是有关使蛋糕在IIS上工作的相关问题: CakePHP 2.2.2无法在Windows IIS7上运行
Here is a related question about getting cake to work on IIS: CakePHP 2.2.2 not working on Windows IIS7
这篇关于Cakephp不加载css和js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!