Q&A
実現したいこと
nginxのkusanagi9 で
/etc/opt/kusanagi/nginx/conf.d/*.conf
への記述で、同一ドメインで旧タームから新タームへのリダイレクトさせたい。
前提
nginx kusanagi9 でWordpressを運用しています。同一ドメイン(hostname)で
https://www.hostname/aaa/bbb/ccc/ddd/eee/
から
https://www.hostname/aaa/bbb/ccc/ddd/fff/ggg/
へのリダイレクトの設定方法がわかりません。
発生している問題・エラーメッセージ
リダイレクトせず、404.phpページが表示される。
該当のソースコード
perl
1 2server { 3 listen 80; 4 5 server_name hostname www.hostname; 6 rewrite ^(.*)$ https://hostname$request_uri permanent; # SSL ONLY 7 rewrite ^(.*)$ https://www.hostname$request_uri permanent; # SSL ONLY/ 8 9 set $do_not_cache 1; ## page cache 10 set $expire_days 90; 11 12 access_log /home/kusanagi/hostname/log/nginx/access.log main; 13 error_log /home/kusanagi/hostname/log/nginx/error.log warn; 14 15 charset UTF-8; 16 client_max_body_size 16M; 17 root /home/kusanagi/hostname/DocumentRoot; 18 19 include conf.d/505.inc; 20 include conf.d/favicon.inc; 21 include conf.d/acme.inc; 22 23 include conf.d/hostname.wp.inc; 24 include conf.d/static.inc; 25} 26 27server { 28 listen 443 ssl http2; 29 server_name hostname www.hostname; 30 31 set $do_not_cache 1; ## page cache 32 set $expire_days 90; 33 34 ssl_certificate /etc/letsencrypt/live/hostname/fullchain.pem; 35 ssl_certificate_key /etc/letsencrypt/live/hostname/privkey.pem; 36 ssl_ct off; 37 ssl_ct_static_scts /etc/opt/kusanagi/nginx; 38 39 include conf.d/ssl.inc; 40 ## OCSP stapling 41 ssl_stapling off; 42 ssl_stapling_verify off; 43 resolver 8.8.4.4 8.8.8.8 valid=300s; 44 resolver_timeout 10s; 45 46 access_log /home/kusanagi/hostname/log/nginx/ssl_access.log main; 47 error_log /home/kusanagi/hostname/log/nginx/ssl_error.log warn; 48 49 charset UTF-8; 50 client_max_body_size 16M; 51 root /home/kusanagi/hostname/DocumentRoot; 52 53 include conf.d/505.inc; 54 include conf.d/favicon.inc; 55 include conf.d/acme.inc; 56 57 include conf.d/hostname.wp.inc; 58 include conf.d/static.inc; 59 include conf.d/fcache_purge.inc; 60}
試したこと
上記に追加記述しました。
server { listen 80; server_name www.hostname; location /aaa/bbb/ccc/ddd/eee/ { return 301 https://www.hostname/aaa/bbb/ccc/ddd/fff/ggg/; } }
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。