【问题标题】:image css js not loaded when using htaccess使用 htaccess 时未加载图像 css js
【发布时间】:2016-05-15 09:39:11
【问题描述】:

任何帮助,请在我使用 htaccess 后没有加载图像 js 和 css。我也尝试了很多示例,但仍然无法正常工作。

我的根文件夹是:newstest 包含一些文件夹

www > newstest > css文件夹、js文件夹、images文件夹、articles文件夹

在文件夹中的文章有 index.php 和 .htaccess 文件。

articles文件夹的index.php中的链接文件:

<script src="../js/jquery.min.js" type="text/javascript"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css">

当我在没有 htaccess 的情况下将 index.php 加载到文章文件夹中时,它会加载所有文件(css、js、image..)。但是当我使用 htaccess 时,没有找到所有链接到 index.php 的文件。

这是我的 .htaccess 文件:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]+)/([0-9]+) index.php?c=$1&id=$2

值 c 和 id 刚刚正确过去。

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:

    像下面这样编辑你的行:

    <script src="/newstest/js/jquery.min.js" type="text/javascript"></script>
    <link href="/newstest/css/style.css" rel="stylesheet" type="text/css">
    

    并将这一行添加到您的 .htaccess 中

    RewriteRule ^(css|js|images)/(.*)?$ /$1/$2 [L,QSA,R=301]
    

    【讨论】:

      猜你喜欢
      • 2015-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-07
      • 1970-01-01
      • 1970-01-01
      • 2012-10-04
      相关资源
      最近更新 更多