将 https:// 重定向到 https://www
Redirect https:// to https://www
我有一个带有 DigitalOcean 的 ubuntu 服务器,它使用 forge.laravel.com
进行管理
我在 nginx.conf 文件中尝试了多种不同的方法来将所有可能的场景重定向到我的域 https://www.domain.com
https://www.domain.com = https://www.domain.com -- GREAT
http://domain.com = https://www.domain.com -- GREAT
http://www.domain.com = https://www.domain.com -- GREAT
https://domain.com = https://domain.com -- This should redirect to the www.
这是我的一部分 nginx.conf
server {
listen 80;
server_name domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
listen 80;
server_name www.domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
root /home/forge/default/public;
.... other nginx.conf configuration
谁能告诉我我做错了什么?我试过很多组合。
替换
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
root /home/forge/default/public;
由
server {
listen 443 ssl;
server_name domain.com;
return 301 https://www.domain.com$request_uri;
#INSERT HERE CERTIFICATES DIRECTIVES
}
server {
listen 443 ssl;
server_name www.domain.com;
root /home/forge/default/public;
我有一个带有 DigitalOcean 的 ubuntu 服务器,它使用 forge.laravel.com
进行管理我在 nginx.conf 文件中尝试了多种不同的方法来将所有可能的场景重定向到我的域 https://www.domain.com
https://www.domain.com = https://www.domain.com -- GREAT
http://domain.com = https://www.domain.com -- GREAT
http://www.domain.com = https://www.domain.com -- GREAT
https://domain.com = https://domain.com -- This should redirect to the www.
这是我的一部分 nginx.conf
server {
listen 80;
server_name domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
listen 80;
server_name www.domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
root /home/forge/default/public;
.... other nginx.conf configuration
谁能告诉我我做错了什么?我试过很多组合。
替换
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
root /home/forge/default/public;
由
server {
listen 443 ssl;
server_name domain.com;
return 301 https://www.domain.com$request_uri;
#INSERT HERE CERTIFICATES DIRECTIVES
}
server {
listen 443 ssl;
server_name www.domain.com;
root /home/forge/default/public;