2017-08-16 380 views
0

我試圖在子目錄中運行Rainloop。 http://babylon/webmail。我得到的CSS和JS無法識別。例如:css和圖像無法被nginx識別:資源被解釋爲樣式表,但使用MIME類型text/html傳輸

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

回答

1

我認爲它可以解決你的問題。

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

@Sanan_Guliyev我現在得到一個404的js和css文件。 「open()」/var/www/html/rainloop/v/1.10.5.192/static/js/min/boot.min.js「failed」應該是:「/ srv/rainloop/public_html/rainloop/v/1.10.5.192/static/js/min/boot.min.js」。我在所有這兩個位置都添加了root,但仍不能修復路徑。 – Ruben

+0

爲我工作! –

相關問題