Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
}
share|improve this question

1 Answer 1

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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