如何实现
https://www.abc.com 跳转到 https://abc.com
以及 https://www.abc.com/abc 跳转到 https://abc.com/abc
1 freshmanc 2018-12-11 10:13:05 +08:00 CNAME 就能干这事了吧 |
![]() | 2 xiwangzishi 2018-12-11 10:18:13 +08:00 |
![]() | 3 zpf124 2018-12-11 10:19:28 +08:00 server { listen 80 default_server; listen [::]:80 default_server; # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response. return 301 https://zfly.me$request_uri; } 我是把所有的请求都转到不带 w 的上了, 你如果只需要把 www 转到不带 w 的上,那就把上面的哪个 defalut_server 删了,然后加一行 server_name www.example.com; |
![]() | 4 yantianqi OP @xiwangzishi 对,网上搜索了老半天,突然想到 https 是监听 443,所以配置 443 跳转,是这样配置。 |
![]() | 5 yantianqi OP 总结了一下配置 nginx 跳转过程[配置 nginx]( https://kkfor.com/article/5c0e8bc5ed10584962b64650) |
6 xpresslink &nbs; 2018-12-11 11:10:51 +08:00 直接在 DNS 上添加一条 CNAME 解析一下多好啊,为毛要这么脱了裤子放屁? |
![]() | 7 jarry777 2018-12-11 11:55:04 +08:00 ![]() @xpresslink 1、CNAME 不传递权重 2、CNAME 只是解析,浏览器地址显示的仍然是原地址,在本例中,如果子域名和裸域名证书不同会报错 张口就说一件事是脱裤子放屁只能暴露你的无知和素质低下 |
8 xpresslink 2018-12-11 13:13:41 +08:00 @jarry777 如果需要显示新地址, 现在 DNS 也都支持 301 重定向呀, 绝对比你自己搭的服务器可用性强. |
![]() | 9 Timgle168 2018-12-11 15:42:06 +08:00 配置 nginx 使它强制跳转到 https 就行 |
![]() | 10 lhx2008 2018-12-11 15:43:31 +08:00 via Android @xpresslink dns 301 一般不支持 https |
![]() | 11 talas 2018-12-12 08:24:41 +08:00 via iPhone RewriteEngine on RewriteBase / RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] |
![]() | 12 talas 2018-12-12 08:27:30 +08:00 via iPhone 呃 apache 下这样实现,找找在线工具可以转 nginx。 |
![]() | 13 talas 2018-12-12 08:30:44 +08:00 via iPhone RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^name.org [NC] RewriteRule ^(.*)$ http://name.org/$1 [L,R=301] RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 这个是不带 www 且 http 跳转 https 的 apache 规则 |
![]() | 14 lichao 2018-12-12 08:59:43 +08:00 |