dtqie02844 2017-08-16 14:20 采纳率: 0%
浏览 2391

nginx无法识别css和图像:资源被解释为样式表,但使用MIME类型text / html进行传输

我试图在子目录中运行Rainloop,http://babylon/webmail,得到的CSS和js是不被识别的。例如:

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".

我尝试了一些可能(但没有奏效)的解决方案:

  1. 1、在nginx.conf.中加入"include /etc/nginx/mime.types;"
  2. 2、有人说,php的位置错了,我应该添加fastcgi_split_path_info ^(.+.php)(/.+)$; #this line,但并没有什么用。

    1. 3、我添加了新的CSS和javascript的根,但也没有任何变化。

    我的配置:

    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;
        }
    }
    
  • 写回答

1条回答 默认 最新

  • dongshi8359 2017-08-16 14:37
    关注

    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;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog