
私はWordpressサーバーを持っています。Nginxwww.mydomain.com/A/B
の設定は次のとおりです。
server {
listen 80 default;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /A/B {
try_files $uri $uri/ /A/B/index.php?$args;
}
...
}
これは正常に動作しています。
今やりたいことは、レガシー パスを新しいパスにリダイレクトすることです。
基本的に私が欲しいのはwww.mydomain.com/A/B/C/XXX/YYY/ZZZ
--> ですwww.mydomain.com/A/B/XXX/YYY/ZZZ
。 を削除します/C
。
私は以下でそれができると思います:
location /A/B/C {
try_files $uri $uri/ /A/B/index.php?$args;
}
しかし、うまくいかなかった。そこで私は
location /A/B/C {
proxy_pass http://localhost/A/B; # note the trailing slash here, it matters!
}
/XXX/YYY
の後のパスが必要なので、別の方法が必要かもしれません/C
。
どのような助けでも大歓迎です。ありがとうございます。
答え1
パス要素を削除するには、URL を書き換える必要がありますC
。
例えば:
rewrite ^(/A/B/)C/(.*)$ $1$2 permanent;
server
これをブロック内、またはブロック内に配置できますlocation ^~ /A/B/C/
。