こんにちは、Nginx を使用して特定のページにリダイレクトしようとしています。たとえば、現在のドメインは testing.example.com です。私がアクセスしたいページは testing.example.com/test ですが、リダイレクト元のドメインは t.example.com なので:
t.example.com = testing.example.com/test
助けてくれてありがとう!
すべてのトラフィックをリダイレクトすることだけが必要な場合は、次のサーバー ブロックを使用します。URI を連結する場合$request_uri
は、return ステートメントに追加できます。
$scheme
http
リダイレクト先の場所にプロトコルを保持するために使用されhttps
ます。それ以外の場合は、使用せずにいずれかで置き換えることができます$scheme
server {
server_name t.example.com;
location / {
return 301 $scheme://testing.example.com/test;
}
}
t.example.com location { }
次のようなものを追加します。
rewrite ^(.*) http://testing.example.com/test/$1 permanent;
または単純なリダイレクト
return 301 http://testing.example.com/test/;