非www到 www 的规则
1 | if ($request_uri ~ ^(.*/)index.html$) { |
http 到 https 的
1 | # http to https |
使用了cloudflare的https重定向设置
如果使用了cloudflare,http 到https的转向需要到cloudflare上面设置
How do I redirect all visitors to HTTPS/SSL?
20180307更新
添加两个page rules 301规则也行,之前的always https没这个选项了
1 | curl -X POST "https://api.cloudflare.com/client/v4/zones/<zone_id>/pagerules" \ |
设置好后使用
1 | curl -I http://love4026.org |
[root@centos-1gb-nyc3-01 ~]# curl -I http://love4026.org
HTTP/1.1 301 Moved Permanently
Date: Wed, 07 Mar 2018 02:14:15 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Wed, 07 Mar 2018 03:14:15 GMT
Location: https://www.love4026.org/
Server: cloudflare
CF-RAY: 3f798c2c75a346f8-EWR`