【问题标题】:CSS & JS file not loading in my cakphp appliactionCSS & JS 文件未加载到我的 cakephp 应用程序中
【发布时间】:2020-09-02 11:25:52
【问题描述】:

我在 goDaddy 上托管了一个 cakephp 网站,css 和 js 文件显示 404 错误,页面显示为空白。 我已经对 webroot 和主目录中的 .htaccess 文件进行了更改

www目录下的.htaccess文件

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule    ^(\.well-known/.*)$ $1 [L]
  RewriteRule    ^$    webroot/    [L]
  RewriteRule    (.*) webroot/$1    [L]
</IfModule>

和 webroot 中的 .htaccess 文件

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

我不确定是什么原因。我检查了错误日志并显示了这一点

2020-09-02 08:06:25 错误:[Cake\Routing\Exception\MissingControllerException] 找不到控制器类 Webroot。 请求网址:/webroot/

【问题讨论】:

  • 你是否尝试过 html helper:-( link:book.cakephp.org/3/en/views/helpers/html.html) 用于 js 文件:- $this->Html->script('jquery.min');或 $this->Html->script('/path/to/dir/jquery.min'); js的默认路径是webroot/js

标签: .htaccess cakephp-3.0 web-hosting


【解决方案1】:

尝试在 /webroot .htaccess 文件中使用它

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 2017-03-30
    • 2013-06-19
    相关资源
    最近更新 更多