Lighttpd Rewrite Help (Trailing slash issues)

lighttpd

I have a webapp under an alias on my server. I want this webapp to be redirected to HTTPS://. So here is my code:

alias.url += ( "/email" => "/srv/Applications/email/" )

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

 static-file.etags = "enable"
 etag.use-mtime = "enable"

 $HTTP["url"] =~ "/(plugins|skins|program)" {
  setenv.add-response-header  = ( "Cache-Control" => "public, max-age=2592000")
 }

}

Now the issues is if I access the email at http://site.com/email, it redirects to https://email for some reason, but if you access it at http://site.com/email/ it works fine. I was just wondering if the is a fix to this, or I will have that hanging /email issue stuck =/ Thanks for any help!

Best Answer

Try this:

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

Note: I didn't actually test this.

Related Topic