CSS 使用 .htaccess 时未加载
CSS not loading when using .htaccess
这是我的文件结构: you can see it here 或
-资源/
--css/
---index.css
-src/
--views/
---main.view.php
--main.php
index.php
.htaccess
这是我的.htaccess:
RewriteEngine On
RewriteRule ^(.*)$ index.php?url= [L,QSA]
这就是我在视图中包含 CSS 的方式
<link rel="stylesheet" href="resources/css/index.css">
问题: 当我在 index.php 中包含 main.php(包括视图)时,无论我在哪里,CSS 都不起作用放置 index.css。有什么提示吗?
您需要添加一个规则来排除重写资产
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond !^(index\.php|images|robots\.txt|css)
这是我的文件结构: you can see it here 或
-资源/
--css/
---index.css
-src/
--views/
---main.view.php
--main.php
index.php
.htaccess
这是我的.htaccess:
RewriteEngine On
RewriteRule ^(.*)$ index.php?url= [L,QSA]
这就是我在视图中包含 CSS 的方式
<link rel="stylesheet" href="resources/css/index.css">
问题: 当我在 index.php 中包含 main.php(包括视图)时,无论我在哪里,CSS 都不起作用放置 index.css。有什么提示吗?
您需要添加一个规则来排除重写资产
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond !^(index\.php|images|robots\.txt|css)