在lighttpd中重写后出现错误的PATH_INFO

发布于 2024-10-09 12:25:34 字数 613 浏览 0 评论 0原文

在我的 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 技术交流群。

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

发布评论

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

评论(1

天荒地未老 2024-10-16 12:25:34

如果您想要预先重写的 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.

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