2020-02-18

How to force redirect 301 "www.example.com" to "example.com"

How to force redirect 301 "www.example.com" to "example.com"


1/ CloudFlare: CNAME "www" -> "example.com".
2/ CloudFlare: DISABLE CDN
3/ HaProxy enable redirect 301:
root@srv004:/etc/haproxy/template# cat haproxy_02_http.cfg.temp 
    #13:58 2020.02.18
    redirect prefix https://example.com code 301 if { hdr(host) -i www.example.com }