【问题标题】:file .htaccess and css文件 .htaccess 和 css
【发布时间】:2019-10-02 00:10:37
【问题描述】:

当我编写我的 .htaccess 文件时,我的项目的 css 和 js 不起作用。我使用 MVC 模式,并且在我的 mainController 中,我每次查看视图时都是 require_once。我不明白,为什么使用 .htaccess 文件程序会尝试 require_once 也是 js。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)$ index.php?controller=$1&action=$2 [QSA,L]

这是控制台输出:

资源解释为样式表,但使用 MIME 类型 text/html: "".

jquery.min.js:1 Uncaught SyntaxError: Unexpected token bootstrap.min.js:1 Uncaught SyntaxError: Unexpected token

【问题讨论】:

    标签: .htaccess model-view-controller path


    【解决方案1】:

    请在您的 .htaccess 文件中添加 mime 标头类型,也许会有所帮助

    AddType text/css .css
    AddType text/javascript .js
    

    【讨论】:

      猜你喜欢
      • 2012-10-31
      • 2017-12-22
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 2018-12-05
      • 2012-12-18
      • 2011-10-09
      • 2016-02-08
      相关资源
      最近更新 更多