Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
6
Help us understand the problem. What is going on with this article?

More than 3 years have passed since last update.

@noracorn92

Wordpress+Nginxのパーマリンク設定

Wordpressでパーマリンク設定を変更すると404になる

誰もが経験したことのあるパーマリンク設定の404。
ページがナッシングだぜでお困りのそこのあなた。
Nginxの設定を書いておきます。

Wordpressのパーマリンク設定

設定を以下のようにしてみた。
image.png

これで、各個別記事、管理者画面、ログアウト画面で404になります。

Nginxの設定

/etc/nginx/conf.d/domainname.conf
server {
    listen       80;
    client_max_body_size 20M;
    server_name  domainname.net;
    root         /var/www/html/domainname;
    index        index.php index.html;

    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/html/domainname$fastcgi_script_name;
        #fastcgi_param  PATH_INFO $fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_read_timeout 180;
    }


    include /etc/nginx/default.d/*.conf;

    location / {
        try_files $uri $uri/ @wordpress;
    }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/html/domainname$fastcgi_script_name;
        include fastcgi_params;
    }

    location @wordpress {
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME  /var/www/html/domainname/index.php;
        include       fastcgi_params;
    }

    # redirect server error pages to the static page /40x.html
    #
    error_page 404 /404.html;
        location = /40x.html {
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

こんな感じにすると直りました。

6
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
6
Help us understand the problem. What is going on with this article?