FastCGI and static files
Added by cababunga almost 16 years ago
I'm surprised nobody asked about this yet. I seem to be unable to serve robots.txt as a static file from within virtual host, with everything else handled by fastcgi.
The following configuration doesn't find robots.txt:
$HTTP["host"] == "abc.example.org" { server.name = "abc.example.org" alias.url = ( "/robots.txt" => "/var/www/html/robots.txt" ) fastcgi.server = ( "/" => (( "socket" => "/tmp/fcgi.sock", "disable-time" => 1, "check-local" => "disable", "bin-path" => "/var/www/example.fcgi", )) ) }
lighttpd-1.4.22
Replies (4)
RE: FastCGI and static files - Added by icy almost 16 years ago
That's because "/" means a prefix match and / will match every url. Did you try surrounding the fastcgi.server setting by a url conditional?
RE: FastCGI and static files - Added by cababunga almost 16 years ago
Yes, if I wrap it like this:
$HTTP["url"] =~ "^/robots.txt$" { fastcgi.server = ( # usual stuff here... ) }
all within $HTTP["host"] of course,
robots.txt still can't be found and in addition I don't get into my virtual server at all. I understand that "/" matches everything, but on the other hand I don't want to uglify my URLs just so I could serve /robots.txt as a static file.
RE: FastCGI and static files - Added by icy almost 16 years ago
You want the url NOT to match so use !~ instead of =~ (and maybe escape the dot). Oh and a normal != "/robots.txt" would be sufficient too :)
RE: FastCGI and static files - Added by cababunga almost 16 years ago
Uhg, I don't know why I wrote it like this. :-/
Thanks, that was really fast and super helpful.