Fortinet white logo
Fortinet white logo

Script Reference Guide

Rewrite HTTP to HTTPS in location

Rewrite HTTP to HTTPS in location

You can rewrite HTTP request headers to replace all HTTP addresses with HTTPS addresses in the redirect location.

Rewrite the HTTP request header to replace HTTP addresses with HTTPS in the redirect location:
when HTTP_RESPONSE{
loc = HTTP:header_get_value("Location")
if loc then
newloc = string.gsub(loc, "http", "https") --replace all http by https in the redirect location
HTTP:header_replace("Location", newloc);
end
}

Rewrite HTTP to HTTPS in location

Rewrite HTTP to HTTPS in location

You can rewrite HTTP request headers to replace all HTTP addresses with HTTPS addresses in the redirect location.

Rewrite the HTTP request header to replace HTTP addresses with HTTPS in the redirect location:
when HTTP_RESPONSE{
loc = HTTP:header_get_value("Location")
if loc then
newloc = string.gsub(loc, "http", "https") --replace all http by https in the redirect location
HTTP:header_replace("Location", newloc);
end
}