網站裝修紀錄 #3 non-www to www

Winsome on 2020-03-19 Thu

發現網站如果沒有打www.winsomeyang.com,只打winsomeyang.com
就會顯示"你的連線不是私人連線"

01

查了一下,可以寫個netlify.tomlredirects

我是照著這篇的寫法來寫的

[[redirects]]
  from = "https://example.netlify.com/*"
  to = "https://www.example.com/:splat"
  status = 301
  force = true

[[redirects]]
  from = "http://example.netlify.com/*"
  to = "http://www.example.com/:splat"
  status = 301
  force = true

[[redirects]]
  from = "http://www.example.com/*"
  to = "https://www.example.com/:splat"
  status = 301
  force = true