2017-08-05 72 views
0

雖然這個問題已經被回答了很多次,但仍然不適合我。 我在除了Nginx主頁以外的所有頁面上都獲得了404。Nginx與wordpress 404在所有頁面上

我張貼在我的配置如下:

server { 
     listen 80 ; 
     listen [::]:80; 

     root /var/www/html/p/swear; 
     index index.php index.html index.htm; 

     server_name skinnybikiniswimwear.org; 

     location/{ 
       try_files $uri /$uri/ /index.php?args =404; 
     } 


      location ~ \.php$ { 
       fastcgi_split_path_info ^(.+\.php)(/.+)$; 
       try_files $uri /index.php?args =404; 
       fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; 
       fastcgi_index index.php; 
       include fastcgi_params; 
     } 
} 

我無法找到問題在此配置。

WordPress是安裝在:在/ var/www/html等/ P /發誓

感謝

回答

0

前去除斜線試試這個:

location/{ 
       # This is cool because no php is touched for static content. 
       # include the "?$args" part so non-default permalinks doesn't break when using query string 
       try_files $uri $uri/ /index.php?$is_args$args =404; 
    } 


    if (!-e $request_filename) { 
      rewrite ^.*$ /index.php last; 
    } 

配置wordpress與nginx配合工作失敗後,re寫規則解決404錯誤的每個問題。

+0

太好了。這工作,但圖像不渲染。 – viv

+0

好的問題是https。將嘗試修復它。 – viv

0

嘗試在/$uri/

location/{ 
    try_files $uri $uri/ /index.php?$args ; 
} 

location ~ \.php$ { 
    try_files $uri =404; 
    include fastcgi_params; 
    fastcgi_pass php; 
} 
+0

試過。不工作。 – viv

+0

在你說這不起作用之前,你重新啓動了nginx嗎? –

+1

在我看來,除了主頁指向https網址之外,您的其他所有網址均指向https網址,這可能是您爲什麼會收到拒絕連接錯誤的原因。這就是我越來越喜歡的東西。 –

0

圖像並不是因爲你沒有在你的服務器塊中關於圖像。您必須將圖像添加到您的服務器塊中。

例如:

location ~* ^.+\.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mp3)$ { 
     root /home/example/public_html 
    } 
+0

好的,我會檢查這個。謝謝 – viv

+0

@viv沒問題讓我知道這件作品給你。 – Noob

+0

它在我修復https後生效。 – viv

相關問題