views:

37

answers:

1

Hi all, I've been given a lighttpd.conf that someone else wrote and need help working out how to serve it. I'm 90% of the way there but stuck... The index.html page appears, but links and CSS files don't point to the right place.

To clarify, the links and CSS files are all pointing to a 'file:///' URL. So styles.css in the HTML header points to file:///html/styles.css, whereas it should be going to http://example.com/styles.css

Maybe url.rewrite or url.redirect isn't working properly?

server.document-root = "~/html"
server.port = 28001
mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 
)
url.rewrite = (
  "^(.*)/($|\?.*)" => "$1/index.html",
  "^(.*)/([^.?]+)($|\?.*)$" => "$1/$2.html"
)
$HTTP["scheme"] == "http" {
  url.redirect = ( 
                   "^/platform/index.html$" => "/platform",
                   "^/about/company.html$" => "/about/company",,
  )
}

----- UPDATE ------

file:/// problem now solved, thanks to Marcel. However, http://example.com/about/company still doesn't find anything, whereas http://example.com/about/company.html renders OK. Is there a problem with url.rewrite? I'm using v1.4.20 of lighttpd, so maybe I need to change it to rewrite-once or rewrite-final?

A: 

About the original problem: it's not a problem of web server configuration, but of the HTML being served, likely containing the file:// protocol. Use http:// instead.

Regarding the second problem: I'm not an expert in Lighttpd configuration options, but it might help if you exchange those settings in url.redirect and get rid of the trailing commas, like:

  url.redirect = ( 
                   "^/platform$" => "/platform/index.html",
                   "^/about/company$" => "/about/company.html"
  )

(but I'm not sure). See the documentation for examples.

BTW, is mod_redirect loaded in server.modules?

Marcel Korpel
Yep - you're right on both counts - adding 'server.modules = ( "mod_redirect" )' solved the problem. THANK YOU!
AP257