2016-01-24 213 views
1

nginx.conf具有包含本服務器博客:Wordpress和NGINX /可溼性粉劑管理員重定向循環

location ~ \.php$ { 
      root /var/www/html/blog; 
      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 /blog { 
      root /var/www/html/blog; 
      include /etc/nginx/mime.types; 
      try_files $uri $uri/ /index.php?q=$uri&$args; 
    } 

但使用這些設置,當我嘗試訪問/blog/wp-admin我的瀏覽器卡住在一些重定向循環。

如果我將nginx.conf中的根URL更改爲/var/www/html,/blog/wp-admin,但我的帖子永久鏈接會給我一個404錯誤。

我的WP文件位於/var/www/html/blog。我安裝了「SSL不安全內容修復程序」插件,因爲我的圖像在我的網站上給出了混合內容錯誤,其中Cloudflare頁面規則始終使用SSL。

我的WP addressWP home都設置爲http://xxx/blog

任何人修正了類似的東西?

感謝

回答

1

我認爲主要的問題是你的root指令不一致。你的PHP配置在/var/www/html/blog有WordPress,而你的靜態配置在/var/www/html/blog/blog有WordPress。

假設WordPress是安裝在/var/www/html/blog根和中的URI應與/blog/前綴兩個真正的文件和永久鏈接,正確的URI爲切入點應該是/blog/index.php

nginx.conf文件大概應該是:

root /var/www/html; 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    include fastcgi_params; 
} 
location /blog { 
    include /etc/nginx/mime.types; 
    try_files $uri $uri/ /blog/index.php; 
} 

如果你有外server容器內衝突root指令,上述root指令可以放置兩個location未修改內。

我會嘗試/blog/index.php而不是/blog/index.php?q=$uri&$argstry_files最後一個元素,因爲在我的經驗,WordPress的使用REQUEST_URI參數航線的永久鏈接,而不是因爲你已經暗示了q說法,但情況因人而異。

如果你有這根服務器的其他應用程序,並想更徹底隔離WordPress的root,你可能會嵌套PHP所在地塊是這樣的:

location ^~ /blog { 
    root /var/www/html; 
    include /etc/nginx/mime.types; 
    try_files $uri $uri/ /blog/index.php; 

    location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     include fastcgi_params; 
    } 
} 
+0

你是一個英雄,一個學者。可以救我幾個小時。 –

相關問題