了解lighttpd.conf 文件?

发布于 2024-09-05 11:39:58 字数 1221 浏览 2 评论 0原文

我收到了别人编写的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单身情人 2024-09-12 11:39:58

关于最初的问题:这不是 Web 服务器配置的问题,而是所提供的 HTML 的问题,可能包含 file:// 协议。请改用 http://

关于第二个问题:我不是 Lighttpd 配置选项方面的专家,但如果您在 url.redirect 中交换这些设置并去掉尾随逗号,可能会有所帮助,例如:(

  url.redirect = ( 
                   "^/platform$" => "/platform/index.html",
                   "^/about/company$" => "/about/company.html"
  )

但我'我不确定)。有关示例,请参阅文档

顺便说一句,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. Use http:// 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:

  url.redirect = ( 
                   "^/platform$" => "/platform/index.html",
                   "^/about/company$" => "/about/company.html"
  )

(but I'm not sure). See the documentation for examples.

BTW, is mod_redirect loaded in server.modules?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文