nginx 无法识别 css 和图像:资源被解释为样式表,但使用 MIME 类型 text/html 传输 [英] css and images not recognized by nginx: Resource interpreted as Stylesheet but transferred with MIME type text/html
本文介绍了nginx 无法识别 css 和图像:资源被解释为样式表,但使用 MIME 类型 text/html 传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在子目录中运行 Rainloop.http://babylon/webmail.我得到 css 和 js 无法识别.例如:
I'm trying to run Rainloop in a subdirectory. http://babylon/webmail. I get the css and js are not recognized. For example:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://babylon/webmail/rainloop/v/1.10.5.192/static/css/rainloop/v/1.10.5.192/static/css/app.min.css?standard".
我尝试过的一些可能(但没有用)的解决方案:
Some possible (but didnt work) solutions I tried:
- "包含/etc/nginx/mime.types;"在 nginx.conf 中找到.
有人说,php 的位置搞砸了那部分,所以我应该添加这一行:
- "include /etc/nginx/mime.types;" is found in nginx.conf.
Some say, location for php is screwing up that part, so I should add this line:
fastcgi_split_path_info ^(.+.php)(/.+)$;#这一行
fastcgi_split_path_info ^(.+.php)(/.+)$; #this line
但是还是不行.
- 我使用 root 为 css 和 javascript 添加了新位置,但也没有.
我的配置是这样的:(它是一个包含文件)
My config is this one: (it is an included file)
location ^~ /webmail {
root /srv/rainloop/public_html;
try_files $uri $uri/ /webmail/index.php?$query_string;
access_log /srv/rainloop/logs/access.log;
error_log /srv/rainloop/logs/error.log;
index index.php;
access_log /var/log/nginx/scripts.log scripts;
location ~ \.php$ {
#if (!-f $request_filename) { return 404; }
include fastcgi_params;
#fastcgi_split_path_info ^(.+\.php)(/.+)$; #this line
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php;
}
location ~ /\.ht {
deny all;
}
location ^~ /webmail/data {
deny all;
}
}
推荐答案
我认为它可以解决您的问题.
I think that it can solve your problem.
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
这篇关于nginx 无法识别 css 和图像:资源被解释为样式表,但使用 MIME 类型 text/html 传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文