Nginx在所有页面上都有wordpress 404

时间:2017-08-05 13:17:24

标签: php wordpress nginx

虽然这个问题已被多次回答,但仍然不适合我。 我在Nginx主页上的所有页面上都获得了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 / swear

由于

3 个答案:

答案 0 :(得分:0)

尝试删除/$uri/

前面的斜杠
location / {
    try_files $uri $uri/ /index.php?$args ;
}

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

答案 1 :(得分: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时遇到很多失败,重写规则解决了404错误的每个问题。

答案 2 :(得分: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
    }
相关问题