0

What the title says..

www.example.com is defined in lighttpd.conf as a virtual host:

$HTTP["host"] =~ "(^|\.)example.com$" {
        server.document-root = "/usr/www/example.com/http"
        accesslog.filename = "/var/log/www/example.com/access.log"
        $HTTP["url"] =~ ".pl$" {
                cgi.assign = (".pl" => "/usr/bin/perl" )
        }
}

However, instead of going by the files listed in index-file.names (the usual index.html, default.html, etc), i want all requests to the root of the virtual host to be forwarded to /cgi-bin/index.pl. What's the easiest/best way of doing this? This need is a special case, and will only apply to this virtualhost. Is it possible to have that particular virtualhost send a redirect in the header?

mailq
  • 16,882
  • 2
  • 36
  • 66
Jarmund
  • 535
  • 1
  • 6
  • 16

1 Answers1

1

If you want to send an HTTP redirect:

url.redirect = ( "^/$" => "/cgi-bin/index.pl" )

If you want an internal rewrite:

url.rewrite = ( "^/$" => "/cgi-bin/index.pl" )
mgorven
  • 30,036
  • 7
  • 76
  • 121
  • Could you please point me how to do this for any subfolder? For example when user opens /ubus/ internally is executed /ubus/cgi-bin/index.cgi (if exists). This is a default behaviour of BusyBox httpd and I want to support both webservers – Sergey Ponomarev Jan 17 '22 at 21:46
  • @SergeyPonomarev see answer posted to your (same) question at: https://serverfault.com/questions/1090298/lighttpd-execute-cgi-bin-index-cgi-if-exists-in-the-folder – gstrauss Feb 04 '22 at 21:14