Project

General

Profile

[Solved] https redirection except one directory and content

Added by lighttpd-user over 5 years ago

hello,

is it possible to configure a generaly https redirection with one exception for a subfolder and the content?
actually my configuration is below:

$SERVER["socket"] == "XXX.XXX.XXX.XXX:80" {
    $HTTP["host"] =~ "(.*)" {
               $HTTP["url"] != "/folder/file1.ini" {
               $HTTP["url"] != "/folder/file2.ini" {
               $HTTP["url"] != "/folder/file3.ini" {
                       url.redirect = ( "^/(.*)" => "https://%1/$1" )
               }
               }
               }
    }
}

But it doesnt work.

Regards


Replies (2)

RE: https redirection except one directory and content - Added by gstrauss over 5 years ago

The %1 match must be from the condition directly above its use.

$SERVER["socket"] == "XXX.XXX.XXX.XXX:80" {
  $HTTP["url"] != "/folder/file1.ini" {
    $HTTP["url"] != "/folder/file2.ini" {
      $HTTP["url"] != "/folder/file3.ini {
        $HTTP["host"] =~ "(.*)" {
          url.redirect = ( "^/(.*)" => "https://%1/$1" )
        }
      }
    }
  }
}

With lighttpd 1.4.50 and later, it can also be more simply:

$SERVER["socket"] == "XXX.XXX.XXX.XXX:80" {
  $HTTP["url"] !~ "^/folder/(file1|file2|file3).ini$" {
    url.redirect = ( "" => "https://${url.authority}${url.path}${qsa}" )
  }
}

RE: [Solved] https redirection except one directory and content - Added by lighttpd-user over 5 years ago

Thanks a lot - it works.

    (1-2/2)