LoginSignup
5
6

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-10-23

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 {
    }

}

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

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6