我收到了一个其他人写过的lighttpd.conf,需要帮助来解决如何服务它。我90%的方式但是卡住了...... index.html页面出现了,但链接和CSS文件没有指向正确的位置。
为了澄清,链接和CSS文件都指向'file:///'URL。因此,HTML标头中的styles.css
指向file:///html/styles.css
,而应该转到http://example.com/styles.css
也许url.rewrite或url.redirect无法正常工作?
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",,
)
}
-----更新------
由于马塞尔, file:///
问题现在已经解决了。但是,http://example.com/about/company仍然找不到任何内容,而http://example.com/about/company.html呈现正常。 url.rewrite有问题吗?我正在使用lighttpd的v1.4.20,所以我可能需要将其更改为重写一次或重写最后一次?
答案 0 :(得分:1)
关于原始问题:这不是Web服务器配置的问题,而是提供的HTML,可能包含file://
协议。请改用http://
。
关于第二个问题:我不是Lighttpd配置选项的专家,但如果您在url.redirect
中交换这些设置并删除尾随逗号,它可能会有所帮助,例如:
url.redirect = (
"^/platform$" => "/platform/index.html",
"^/about/company$" => "/about/company.html"
)
(但我不确定)。有关示例,请参阅the documentation。
顺便说一句,mod_redirect
加载server.modules
?