开发者

Get wrong PATH_INFO after rewriting in 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:开发者_如何学JAVA//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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜