了解lighttpd.conf 文件?
我收到了别人编写的 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:///
问题现已解决,感谢 Marcel。但是, http://example.com/about/company 仍然找不到任何内容,而 < a href="http://example.com/about/company.html" rel="nofollow noreferrer">http://example.com/about/company.html 渲染正常。 url.rewrite有问题吗?我使用的是lighttpd v1.4.20,所以也许我需要将其更改为rewrite-once或rewrite-final?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于最初的问题:这不是 Web 服务器配置的问题,而是所提供的 HTML 的问题,可能包含
file://
协议。请改用http://
。关于第二个问题:我不是 Lighttpd 配置选项方面的专家,但如果您在
url.redirect
中交换这些设置并去掉尾随逗号,可能会有所帮助,例如:(但我'我不确定)。有关示例,请参阅文档。
顺便说一句,
mod_redirect
是否已加载到server.modules
中?About the original problem: it's not a problem of web server configuration, but of the HTML being served, likely containing the
file://
protocol. Usehttp://
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:(but I'm not sure). See the documentation for examples.
BTW, is
mod_redirect
loaded inserver.modules
?