前提・実現したいこと
WordPressのパーマリンクをカスタム構造(下記形式)に変更し、
・WordPress管理ページから正常に投稿、編集等が可能になる
・形式に沿ったURLを叩くと正常なページが表示される
http://localhost/wordpress/info/%year%%monthnum%%day%/%post_id%/
発生している問題・エラーメッセージ
下記2点の問題が確認されています。
(1)カスタム構造に変更し、記事を新規公開しようとすると「公開に失敗しました」というエラーが発生する。
(2)既存記事の詳細(?)を見ようとリンクを押下すると"http://localhost/index.php"の内容が表示される。
URLが下記形式になっているのでパーマリンク設定の変更はできている。
http://localhost/wordpress/info/20190722/1/
試したこと
"default.conf"に下記を追記しました。
追記前は404に転送されていましたので、下記記述は機能はしているようです。
default
1/etc/nginx/sites-available/default.conf 2 3 if (-f $request_filename) { 4 expires 30d; 5 break; 6 } 7 8 if (!-e $request_filename) { 9 rewrite ^.+?($/wp-.*) $1 last; 10 rewrite ^.+?(/.*.php)$ $1 last; 11 rewrite ^ /index.php last; 12 }
補足情報(FW/ツールのバージョンなど)
環境情報は下記の通りです。
Ubuntu
1Linux version 4.18.0-21-generic (buildd@lcy01-amd64-006) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #22~18.04.1-Ubuntu SMP Thu May 16 15:07:19 UTC 2019
PHP
1PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS ) 2Copyright (c) 1997-2018 The PHP Group 3Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
nginx
1nginx version: nginx/1.16.0
default
1/etc/nginx/sites-available/default.conf 2 3server { 4 listen 80; 5 server_name localhost; 6 charset UTF-8; 7 client_max_body_size 10m; 8 access_log /var/log/nginx/hoge.access.log; 9 error_log /var/log/nginx/hoge.error.log; 10 11 location / { 12 root /home/web/html/hoge; 13 index index.html index.htm index.php; 14 15 if (-f $request_filename) { 16 expires 30d; 17 break; 18 } 19 20 if (!-e $request_filename) { 21 rewrite ^.+?($/wp-.*) $1 last; 22 rewrite ^.+?(/.*.php)$ $1 last; 23 rewrite ^ /index.php last; 24 } 25 } 26 27 error_page 500 502 503 504 /50x.html; 28 location = /50x.html { 29 root /home/web/html; 30 } 31 32 location ~ .php$ { 33 root /home/web/html/hoge; 34 try_files $uri $uri/ /index.php$args; 35 fastcgi_pass unix:/run/php/php7.2-fpm.sock; 36 fastcgi_index index.php; 37 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 38 include fastcgi_params; 39 } 40}
その他必要な情報がありましたらご指示ください。
あなたの回答
tips
プレビュー