部署在Nginx的wordpress全部页面都出现404错误

文章目录

[隐藏]

  • 问题
  • 最佳答案
问题

虽然这个问题网上已经有很多人回答过了,但是还是不能解决我的问题。Nginx上的wordpress,除了首页外,其它页面全部出现404。
下面是nginx的配置:

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/swear。
多谢.

最佳答案

尝试如下配置:

    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不成功,大多数是重写规则不对导致的404问题。

原文出处:stackoverflow -> https://stackoverflow.com/questions/45522358/nginx-with-wordpress-404-on-all-pages

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-05-05 16:39:02
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[加我微信]
chaoneo
注:点击复制微信号并打开微信APP,添加好友后进行聊天。
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: