![lighttpd 配置文件无法解析 $HTTP["url"] 条件配置,但其他配置可以正常工作](https://linux22.com/image/657294/lighttpd%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%97%A0%E6%B3%95%E8%A7%A3%E6%9E%90%20%24HTTP%5B%22url%22%5D%20%E6%9D%A1%E4%BB%B6%E9%85%8D%E7%BD%AE%EF%BC%8C%E4%BD%86%E5%85%B6%E4%BB%96%E9%85%8D%E7%BD%AE%E5%8F%AF%E4%BB%A5%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
我正在尝试为服务器上特定路径上的文件设置 mimetypes,该服务器运行带有 SSL 的 lighttpd 版本 1.4.31。
我正在遵循该配置文档:http://redmine.lighttpd.net/projects/1/wiki/docs_configuration
直到 lighttpd 1.5.0 版本才具有指定功能$PHYSICAL["path"]
,因此我尝试指定$HTTP["url"]
。
我已经尝试过了
$HTTP["url"] == '/my_path/directory_to_affect/foo.html' {
# my settings are in here
}
和
$HTTP["url"] =~ '/my_path/directory_to_affect/*' {
# my settings are in here
}
如果我测试我的配置文件lighttpd -D -f lighttpd.conf
或尝试重新启动 lighttpd,我会收到此错误:
2015-04-29 14:37:52: (configfile.c.892) source: /etc/lighttpd/lighttpd.conf line: 48 pos: 12 invalid character in variable name
2015-04-29 14:37:52: (configfile.c.948) configfile parser failed at: ==
或者出现同样的错误,但显示=~
的不是==
。
令我困惑的是,已经存在其他条件配置,例如 where $SERVER["socket"] == ":80"
,并且这些配置工作正常。
答案1
根据lighttpd 配置文件语法文档,仅支持双引号"
,不'
支持。
您的观察虽然$SERVER["socket"] == ":80"
有效,但$HTTP["url"] == '/my_path/'
事实并非如此,证实了这一点。