Project

General

Profile

Actions

HowToRedirectHttpToHttps » History » Revision 2

« Previous | Revision 2/33 (diff) | Next »
Anonymous, 2006-08-15 21:56
fixed 2 spelling mistakes


= How to redirect HTTP requests to HTTPS =

As of version 1.4.11 this is as simple as:

{{{
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "example.org" {
url.redirect = ( "^/(.*)" => "https://example.org/$1" )
server.name = "example.org"
}
}

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/path/to/example.org.pem"
server.document-root = "..."
}
}}}

(Note: this also works in versions prior to 1.4.11 providing you have not specified {{{server.port = 80}}} in your configuration file.)

To redirect ''all'' hosts to their secure equivalents use the following in place of the socket 80 configuration above:

{{{
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "(.*)" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
}
}}}

----
The information was taken from two postings to the mailing list by Jan:

Updated by Anonymous over 17 years ago · 2 revisions