Cakephp not loading css and js files

耗尽温柔 提交于 2019-12-11 05:42:51

问题


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 could not be found."

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 files are placed in:

 app\webroot\css

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.


回答1:


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>

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!

also check if mod_rewrite is enabled

Edit: and then I saw the IIS part, you need some IIS equivalent to mod_rewrite

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

Here is a related question about getting cake to work on IIS: CakePHP 2.2.2 not working on Windows IIS7



来源:https://stackoverflow.com/questions/17533702/cakephp-not-loading-css-and-js-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!