2017-08-05 97 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