修剪.htaccess静态文件问题

时间:2016-02-20 08:53:33

标签: php apache .htaccess mod-rewrite slim

这是我的结构:

- app
  - assets 
    - css
    - js
  - views
    index.html
- vendor
.htaccess
index.php

的.htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(assets|bower_components|dist)/(.*)$ /app/$1/$2 [L,NC]

RewriteCond %{REQUEST_URI} !^assets|bower_components|dist/.*$
RewriteRule ^ index.php [L,QSA]

我的问题是当我尝试加载时:

/assets/css/style.css

来自index.html它给了我404

为什么会这样?

3 个答案:

答案 0 :(得分:2)

在.htaccess文件更改

RewriteBase /

RewriteBase /assets 

答案 1 :(得分:1)

删除RewriteBase指令:

RewriteBase /

看来你的项目不在域根目录。

答案 2 :(得分:1)

RewriteBase /
to
RewriteBase /assets
so that it works in .htaccess