在lighttpd中重写后出现错误的PATH_INFO
在我的 lighttpd 配置文件中,我有这样的重写规则:
$HTTP["host"] == "sub.example.com" {
url.rewrite = (
"^/(.*)" => "/sub/$1"
)
}
因此,当用户访问 http://sub.example.com 时,她实际上正在访问 http ://example.com/sub。
问题是 PATH_INFO
似乎是错误的,
URL: http://sub.example.com/extra
PATH_INFO:
expected: /extra
what I get: /sub/extra
现在每当我调用 request.get_path()
时,它都会返回类似 http://sub.example.com/ 的内容sub/extra
,这不是我想要的。
当然,我可以覆盖 request
类的 get_path
方法,但我想知道是否有更简单的方法,例如更改lighttpd配置?
In my lighttpd
config file, I have a rewrite rule like this:
$HTTP["host"] == "sub.example.com" {
url.rewrite = (
"^/(.*)" => "/sub/$1"
)
}
So when a user visits http://sub.example.com
, she's actually visiting http://example.com/sub
.
The problem is that the PATH_INFO
seems wrong,
URL: http://sub.example.com/extra
PATH_INFO:
expected: /extra
what I get: /sub/extra
Now whenever I call request.get_path()
, it returns something like http://sub.example.com/sub/extra
, which is not what I want.
Of course, I can just override the get_path
method of the request
class, but I wonder if there is a simpler way like changing the lighttpd config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要预先重写的 URI,请尝试
REQUEST_URI
。一般来说,如果您有重写规则,那么它就是您真正想要的重写路径,否则重写就没有意义。If you want pre-rewritten URI try
REQUEST_URI
. Generally if you have rewrite rules it is the rewritten path you actually want otherwise there is no purpose to the rewriting.