2016-04-22 105 views
0

我正在使用以下設置在同一個域上運行2個應用程序。如果第一個應用程序返回404,它會嘗試另一個(wordpress on/blog)。nginx加載資產但未顯示wordpress應用程序

location /blog { 
    root /var/www/blog; 
    index index.html index.htm index.php; 
    try_files $uri $uri/ /blog/index.php?$args; 

    location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      include fastcgi_params; 
    } 
} 
location/{ 
    # ... 
    proxy_intercept_errors on; 
    recursive_error_pages on; 
    error_page 404 =200 /blog/$uri; 
} 

每個頁面按預期載入,資產返回200和正確的內容。 但這些資產的css和大多數圖像不適用於頁面,而一些工作很好。 下面是包括:

include /etc/nginx/mime.types; 

我明白,這可能是一個錯誤的配置,但無論如何在我的理解它仍然應該工作。 是否有另一種配置來實現類似的東西?

編輯: 的WordPress安裝位於在/ var/WWW /博客/博客/

回答

0

我不能確切地明白這個問題,但我建議你帶出外面是PHP的阻止和刪除博客和在index.php之後的$ args uri。

試試這個,而不是讓我知道這是否解決。 :)

location /blog { 
    root /var/www/blog; 
    index index.html index.htm index.php; 
    try_files $uri $uri/ /index.php; 
} 
location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
} 
location/{ 
    # ... 
    proxy_intercept_errors on; 
    recursive_error_pages on; 
    error_page 404 =200 /blog/$uri; 
} 
+0

以某種方式以外的PHP塊不起作用。 $ args是wordpress工作所必需的,並且博客是必需的,因爲wordpress在/ var/www/blog/blog中。 – Jesse