Php css文件在使用.htaccess文件时停止工作

Php css文件在使用.htaccess文件时停止工作,php,apache,.htaccess,Php,Apache,.htaccess,我正在尝试为我的网站创建干净的URL,因此我创建了一个.htaccess文件,如下所示: Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^product/(\w+)/(\w+)$ product.php?id=$1 RewriteRule ^product/(\w+)/(\w+)$ produc

我正在尝试为我的网站创建干净的URL,因此我创建了一个.htaccess文件,如下所示:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^product/(\w+)/(\w+)$ product.php?id=$1
RewriteRule ^product/(\w+)/(\w+)$ product.php?id=$1

RewriteRule ^store/(\w+)/(\w+)$ Store.php?id=$1
RewriteRule ^store/(\w+)/(\w+)$ Store.php?id=$1
现在它工作得很好,但是当我浏览页面时,我看到设计没有css也没有图像,那么你认为问题出在哪里


最重要的问题可能是CSS文件(和图像等)的相对路径。在标题中使用绝对路径或基本标记

<base href="http://www.example.com/" />

在HTML页面中,在指向CSS文件的链接前面加上
/

因此,如果您有:

<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />

将其更改为:

<link rel="stylesheet" type="text/css" href="/css/stylesheet.css" />


这使CSS的路径成为绝对路径,这样无论浏览器认为它在哪个“文件夹”中,它都会找到CSS。

这取决于CSS和js文件的位置。使用浏览器开发工具查看浏览器在哪里查找这些文件我想说的是,前两条规则可能会阻止css。尝试对它们进行注释,看看会发生什么。我尝试打开此url:浏览器正在尝试查找加载资源失败处的css:服务器响应状态为404(未找到)。我尝试了此操作,浏览器仍在尝试从加载资源失败处加载css:服务器响应状态为404(未找到)当我试图打开这个url:localhost/template/product/75/22,并且在您的光盘路径{localhost\u root}/template/product/75/css/stylesheet.css存在时?css在{localhost\u root}/template/css/stylesheet.csand product.php和Store.php在localhost\u root中?