Project

General

Profile

Adding HTTPS support

Added by jrsimma over 5 years ago

I've tried to research how to migrate our site to HTTPS, without breaking our current configuration. For example, we have some 301 redirects for individual pages, and also redirect our domain to the www subdomain. Does the below look correct? The first part is to redirect individual files, the second section to redirect http to https, and the third is to redirect our domain to the www subdomain. Thanks for the help.

# 301 Perm. moved redirect for https://www.simmasoftware.com/index.html
$HTTP["host"] =~ "^www\.simmasoftware\.com" {
    url.redirect = (
        "^/j1939-0.html$" => "https://www.simmasoftware.com/sae-j1939-0.html",
        "^/j1939-11.html$" => "https://www.simmasoftware.com/sae-j1939-11.html",
        "^/j1939-14.html$" => "https://www.simmasoftware.com/sae-j1939-14.html" 
    )
}

# 301 Perm. moved redirect for http to https
$HTTP["scheme"] == "http" {
    # capture vhost name with regex conditiona -> %0 in redirect pattern
    # must be the most inner block to the redirect rule
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}

# 301 Perm. moved redirect for https://simmasoftware.com/ to https://www.simmasoftware.com
$HTTP["scheme"] == "https" {
  $HTTP["host"] =~ "^simmasoftware\.com$" {
    url.redirect = (
        "^/(.*)" => "https://www.simmasoftware.com/$1" 
    )
  }
}