[英]how redirect domain from nginx to another domain which is working on same nginx?
我在數字海洋中有一個服務器小滴,兩個域指向該服務器 A.com 和 B.com。 我希望當 A.Com 被調用時,nginx 將它重定向到 B.com 和服務器作為 B.com 。 例如,如果用戶從瀏覽器 B.com 中點擊 url,則應顯示我的站點,但如果它點擊 A.com,則應打開同一站點,但域更改為 B.com
這是一些如何做到這一點的例子:
server {
listen 443 ssl http2;
server_name a.com;
location / {
return 301 $scheme://b.com$request_uri;
}
}
添加此服務器塊
這是重定向
server {
listen 80;
server_name example.com; // your domain name
location / {
return 301 https://redirect-to.com; //Add your redirect url here
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.