0
  $HTTP["scheme"] == "http" {
    $HTTP["host"] =~ "^(.*)$" {
      url.redirect = ("^/folder/(.*)$" => "https://%1/$1")
    }
  }

Obviously, the %1 is inserting the host - but where is getting it from? My first thought is in from the line above it where it is matching against the host, but that doesn't seem right.

Is %1 is a built-in placeholder for the hostname or is it coming from the previous "host" match?

doremi
  • 14,921
  • 30
  • 93
  • 148

1 Answers1

1

From the documentation of url.redirect: -

Note that the "%1" in the url.redirect target refers to the parenthesized subexpression in the conditional regexp (.*). It does not necessarily have the meaning that "%1" would have in evhost.path-pattern (where it would mean 'top-level domain'). If url.redirect is specified within a regex conditional, % patterns are replaced by the corresponding groups from the condition regex. %1 is replaced with the first subexpression, %2 with the second, etc. %0 is replaced by the entire substring matching the regexp. See above and below for examples using % patterns.

Rohit Jain
  • 209,639
  • 45
  • 409
  • 525