部署在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问题。

标签:部署WordPressNginx 发布于:2019-11-13 23:49:52