我似乎无法在同一个网址上同时进行身份验证和重写。如果我禁用一个,另一个工作。这在lighttpd中是否可行?
$HTTP["host"] =~ "www\.example\.com$" {
auth.require = (
"/prettyurl" =>
(
"method" => "basic",
"realm" => "Password reqired",
"require" => "valid-user"
)
)
url.rewrite = (
"/prettyurl" => "/index.php?foo=bar&goo=car"
)
}
答案 0 :(得分:2)
我通常将auth.require
封装在$HTTP["url"]
中。这样的事情:
$HTTP["host"] =~ "www\.example\.com$" {
url.rewrite = (
"/prettyurl" => "/index.php?foo=bar&goo=car"
)
$HTTP["url"] == "/index.php" {
$HTTP["querystring"] == "foo=bar&goo=car" {
auth.require = ( "" =>
(
"method" => "basic",
"realm" => "Password reqired",
"require" => "valid-user"
)
)
}
}
}
答案 1 :(得分:1)
我找到了解决方法。似乎auth.require
和$HTTP["url"]
在网址的查询字符串部分都不匹配。
首先制作符号链接
ln -s index.php index_auth.php
然后在lighttpd conf:
$HTTP["host"] =~ "www\.example\.com" {
url.rewrite = (
"/prettyurl-auth" => "/index_auth.php?foo=bar",
"/prettyurl-noauth" => "/index.php?goo=car"
)
auth.require = ( "/index_auth.php" =>
(
"method" => "basic",
"realm" => "Password reqired",
"require" => "valid-user"
)
)
}
如果有更好的方式,请告诉我!