Appendix C: Scripts : Examples : Redirect HTTP to HTTPS using Lua string substitution
 
Redirect HTTP to HTTPS using Lua string substitution
You can use the content rewriting feature to redirect an HTTP request to an HTTPS URL that has the same host and request URL using a PCRE regular expression. If you are more comfortable using Lua string substitution, you can write a script to get the results you want. The following example redirects users to the HTTPS location.
 
-- Redirect HTTP to HTTPS
when RULE_INIT {
debug("http to https redirect\n")
}
 
when HTTP_REQUEST{
host = HTTP:header_get_value("Host")
path = HTTP:path_get()
HTTP:redirect("https://%s%s",host,path);
}