-1

I have the following piece in my config file:

cgi.assign = ( ".sh" => "" )

$HTTP["url"] =~ "^/urlpath/" {
  $HTTP["querystring"] =~ "cams=on" {
    cgi.assign = ( "" => "/scriptpath/CamsOn" )
  }
  $HTTP["querystring"] =~ "cams=off" {
    cgi.assign = ( "" => "/scriptpath/CamsOff" )
  }
  url.redirect = ( "^/urlpath/" => "http://somewebsite" )
}

I have the cgi module loaded:

server.modules              = (
                                "mod_redirect",
                                "mod_access",
                                "mod_cgi",
                                "mod_accesslog" )

Now "CamsOn" and "CamsOff" are shebanged shell scripts. To be honest I had done this before and had it working but my server crashed and I lost my configs. For some reason I can't figure for the life of me how to get it working. I do the redirect so I don't have to actually create the "urlpath" page. The redirect works fine inside the $HTTP["url"] piece, and I've even tested the querystring portion by nesting a redirect inside that just takes it to google.com; urlpath/?cams=on sent me to google accordingly.

What am I doing wrong?

Update:

I was to get it to work using

$HTTP["url"] =~ "^/urlpath/" {
  $HTTP["querystring"] =~ "cams=on" {
    cgi.assign = ( "" => "/scriptpath/CamsOn" )
  }
  $HTTP["querystring"] =~ "cams=off" {
    cgi.assign = ( "" => "/scriptpath/CamsOff" )
  }
}

I'm thinking that the redirect was getting parsed first, so when the address changed, it no longer fit the URL and querystring comparisons. Can I change this? The idea is to make the urlpath dynamic and updated in the conf file dynamically. This is why I have the redirect send you to another address. This way I also don't need to do html editing or create additional folders.

user3377627
  • 363
  • 3
  • 7
  • 22

1 Answers1

0

What am I doing wrong?

a) did not make backups

b) did not make backups

c) did not make backups

d) did not look in your own stackoverflow post history

See Can't figure out how to receive http requests using lighttpd

If you want to reduce the number of places you edit in your config file, you can assign a value to a variable in lighttpd.conf and use the variable in lighttpd.conf. See var.* in https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration var.camsurlpath = "/urlpath/" $HTTP["url"] =~ "^" + var.camsurlpath { ... }

Community
  • 1
  • 1
gstrauss
  • 2,091
  • 1
  • 12
  • 16