我的css文件有一个奇怪的问题。 我将htaccess文件更改为此
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} /eventDetails\.php\?id=([0-9]+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [L,R]
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]
</IfModule>
我的css文件停止加载到网站的所有页面。
我的public_html文件夹包含
使用Google Chrome开发者工具我的css文件出现此错误
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://something.gr/css/style.css".
和javascript文件的此错误
owl.carousel.js:1 Uncaught SyntaxError: Unexpected token <
Network
标签中的一些图片。
没有.htaccess文件
正如您所看到的,Content-Type是text / css ..就像它应该是
WITH .htaccess文件
正如您在此处所看到的,mime.type将其作为text / html
返回我尝试了什么。
首先。在<title>
html标签后我输入了网络
<base href="/">
二。我试图将.htaccess文件更改为此
<IfModule mod_rewrite.c>
RewriteEngine on
AddType application/javascript js
AddType text/css css
RewriteCond %{THE_REQUEST} /eventDetails\.php\?id=([0-9]+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [L,R]
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]
</IfModule>
最后我检查了我的专用服务器usr/local/apache/conf/
在mime.types文件中,text/css css
的注释与...相同
application/javascript js
我不知道还应该做些什么。
答案 0 :(得分:2)
你的第二条规则
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]
将/css/style.css
重写为/eventDetails.php?id=css&name=style.css
。
如果要从此规则中排除现有文件,可以在其前面加上
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
您可能也会将第一条规则更改为
RewriteCond %{QUERY_STRING} id=([0-9]+)&name=(.+)
RewriteRule ^eventDetails\.php$ /%1/%2? [L,R]
并阻止我们在开头插入的重定向循环
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
如果您将现有条件和规则与THE_REQUEST
保持一致,那么您当然不需要这样做。
所以完整的规则变为
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{QUERY_STRING} id=([0-9]+)&name=(.+)
RewriteRule ^eventDetails\.php$ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]