2016-07-18 102 views
0

我正在使用nginx/1.4.6 Ubuntu 14.04.4 LTS。 我有一個SSL虛擬主機看起來始於follwingnginx重定向匹配servname和多名虛擬主機位置

server { 
     listen 443 default_server ssl; 
     server_name example1.com example2.com example3.com; 

你怎麼會寫重定向,這樣,如果任何匹配example2.com/location*被重新寫入example2.com/page.html?

感謝

回答

0

有三個變量,它可以幫助你確定接受請求的服務器的名稱:$host$http_host$server_name

要執行你的問題表明的外部重定向,你可以使用:

location /location { 
    return 301 $scheme://$host/page.html; 
} 

詳見this document

+0

謝謝,我試過你的建議和它的工作 – saiyen2002