I'm trying to send any request to the index.html with lighttpd in order to prevent 404 but I'm not smart enough because either the redirect matches itself or, for calls to subdirs, although the index.html gets served, it is not served from document root so all the paths are off and thus no images are shown.

$HTTP["host"] == "my.example.com" {
    server.document-root = "/var/www/my/html/"
#       url.rewrite-once = ( "^/([^\./]+)/?([^\./]+)?(/|\.html)?$" => "/index.php?a=$1&b=$2" )
#       url.rewrite-once = ( "^.+?" => "/" )
#       url.redirect = ( ".*" => "http://my.example.com/index.html" ) # too many redirects
}
link|improve this question
feedback

1 Answer

A few moments with Google suggests you want:

server.error-handler-404   = "/index.html"

No, I don't want to handle the error. I want all requests to go to /index.html

You said you wanted to prevent a 404, this will do that. As the error is then handled it returns a 200 status code by default.

And this also fails for my.example.com/some/thing.ext because the page is sent from /some/ so all paths are off.

No, it won't fail - it redirects all misses to /index.html. That said, try:

url.rewrite-once = ( "^/(.*)" => "/index.html" )

That will, once, rewrite any URL to /index.html.

link|improve this answer
No, I don't want to handle the error. I want all requests to go to /index.html – None Feb 26 '11 at 10:01
And this also fails for my.example.com/some/thing.ext because the page is sent from /some/ so all paths are off. – None Feb 26 '11 at 10:28
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.