0

BusyBox httpd executes the ./cgi-bin/index.cgi if it exists. This is similar to index.php but with the /cgi-bin/ folder. So for example I have the structure:

/api/
  cgi-bin/index.cgi
/blog/
  cgi-bin/index.cgi
  /rss/
    cgi-bin/index.cgi

So when request are going to http://example.com/api/ they are actually handled by the /www/api/cgi-bin/index.cgi script. When requested http://example.com/blog/ it's processed by /www/blog/cgi-bin/index.cgi but the /blog/rss/ path is processed by /www/blog/rss/cgi-bin/index.cgi.

But now I also want to support the Lighttpd webserver. How can I achieve that?

This seems similar to Making lighttpd redirect from www.example.com to www.example.com/cgi-bin/index.pl but much more complicated.

1 Answers1

1

The simplest solution is to use lighttpd mod_indexfile:

index-file.names = ( "cgi-bin/index.pl" )

An alternative if you want to internally rewrite the target, try lighttpd mod_rewrite:

Generically:

url.rewrite-once = ( ".*/(?:\?|$)" => "${url.path}cgi-bin/index.pl${qsa}" )

More precisely for only the paths in your example:

url.rewrite-once =
  ( "^/(?:api|blog(?:/rss)?)/(?:\?|$)" => "${url.path}cgi-bin/index.pl${qsa}" )
gstrauss
  • 221
  • 1
  • 5