Lighttpd:将任何请求redirect到index.html

我试图用lighttpd发送任何请求到index.html为了防止404,但我不够聪明,因为redirect匹配自己,或者对于调用subdirs,尽pipeindex.html得到服务,它是没有从文档根目录中提交,因此所有的path都closures,因此没有显示图像。

$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 } 

Google提示你想要:

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

不,我不想处理这个错误。 我想要所有的请求去/index.html

你说你想阻止一个404,这将做到这一点。 随着错误被处理,它默认返回一个200状态码。

而且这也是my.example.com/some/thing.ext失败的原因,因为页面是从/ some /发送的,所以所有的path都closures了。

不,它不会失败 – 它将所有的错误redirect到/index.html 。 这就是说,试试:

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

一旦将任何URL重写为/index.html