php - nginx : Resource interpreted as Stylesheet but transferred with MIME type text/html 无法识别 css 和图像

标签 php nginx webserver mime-types

我正在尝试在子目录中运行 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. “包括/etc/nginx/mime.types;”在 nginx.conf 中找到。
  2. 有人说,php 的位置搞砸了那部分,所以我应该添加这一行:

    fastcgi_split_path_info ^(.+.php)(/.+)$; #这一行

但是还是不行。

  1. 我使用 root 为 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;
    }
}

最佳答案

我认为它可以解决您的问题。

location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}

关于php - nginx : Resource interpreted as Stylesheet but transferred with MIME type text/html 无法识别 css 和图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45716128/

相关文章:

php - MySQL 和 PHPMyAdmin 事件调度程序

redirect - 带或不带尾部斜杠的 Nginx 永久重定向

laravel - 仅在项目的某个目录上的 HTTPServer - NGINX

php - symfony 在何处以及如何存储用户角色

php - 在 camelCased 字符串中的单词之间添加空格,然后大写第一个单词

c++ - 如何调试快速通用网关接口(interface) (FCGI) 程序?

tomcat - Nginx 到 tomcat SSL 连接 |没有共同的密码套件

php - 无法将 $_POST 值传递给 php-cgi

php - 使用 wkhtmltopdf 静态二进制文件时找不到 libjpeg.so.8

php - Laravel 选择默认禁用选项