Reputation: 2080
I have settings to www
rewrite or return.
1:
server {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
2:
server {
listen 80;
server_name example.com;
return 301 https://www.$host$request_uri;
}
Are these two things equal?
It seems to be working well, but I can't have assurance.
Upvotes: 1
Views: 26
Reputation: 49702
It depends on which server
block is the default server for port 80.
If this server
block is also the implicit default server for port 80, it may need to handle requests for server names other than example.com
, in which case the value of $host
will not be equal to the value of $server_name
. See this document for more.
You could use $server_name
instead of $host
. See this document for details.
Upvotes: 1