Replace this:
if ($host = www.$server_name) {
rewrite ^(.*) https://$server_name$request_uri? permanent;
}
server_name yoursay.transport.nsw.gov.au;
with this:
if ($host = www.yoursay.transport.nsw.gov.au) {
return 301 https://yoursay.transport.nsw.gov.au$request_uri;
}
server_name yoursay.transport.nsw.gov.au www.yoursay.transport.nsw.gov.au;
Explanation:
When someone visit your website they sent HTTP request headers. One of them is Host
which is the address they've used to reach the website. It can be an IP-address, www.example.com
, example.com
, or something.completely.irrelevant
. server_name
option defines to which Host
headers this configuration belong. That is why I added www.yoursay.transport.nsw.gov.au
to server_name, so this configuration is used for visitors accessing the address. You may also wish to repeat this in your HTTP server block (the one listening on port 80).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…