我的Webstie托管在AWS EC2实例上,并且具有nginx 1.12.2和Ec2操作系统是centos,如何将http://example.com和https://example.com重定向到https://www.example.com。
谢谢
答案 0 :(得分:0)
您将需要3个服务器部分(我几乎可以确定您忘记处理http://www.example.com情况)
server {
listen 80;
server_name example.com;
location / {
return 301 https://www.example.com$request_uri;
}
...
server {
listen 443 ssl;
server_name example.com;
ssl_certificate ...
location / {
return 301 https://www.example.com$request_uri;
}
...
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate ...
location / {
#your configuration here
}
...