使用lighttpd代理更改QUERYSTRING [英] Change QUERYSTRING with the lighttpd proxy
问题描述
首先,对不起我的英语,希望您能理解.
First of all sorry for my English, hope you can undestand it.
我需要使用Lighttpd更改目标服务器的URL,我的意思是,有人要编写类似 http://XXX.XXX.XXX.XXX/search?q=MYQUERY .
I need to change the URL of the destination server with Lighttpd, I mean, someone is going to write an URL like http://my.proxy.server.com/MYQUERY and I need to change it to something like http://XXX.XXX.XXX.XXX/search?q=MYQUERY.
我尝试添加"querystring"选项,例如下面的配置,但是它不起作用.
I tried to add an "querystring" option like the configuration below but it didn't work.
proxy.server = (
"" =>
(
( "host" => "XXX.XXX.XXX.XXX",
"port" => 80,
"querystring" => "/search?q=$HTTP[querystring]"
)
)
)
我还尝试用下面的代码强制更改URL,但这都不起作用.
I also tried to force changing the URL with the code below but it didn't work neither.
$HTTP["url"] =~ "^/"{
server.querystring = "/search/q=$HTTP[querystring]"
}
我该怎么办? lighttpd有此功能吗?
What can I do? Does lighttpd have this feature?
谢谢
推荐答案
找到了它.首先,我需要激活mod_rewrite,然后在代理配置之前,我只需要重写url,例如:
Found it. First of all I need to have the mod_rewrite activated, then before the proxy configuration I just need to rewrite the url, like:
url.rewrite-once = ( "/(.*)" => "/search?q=$1" )
谢谢大家.
这篇关于使用lighttpd代理更改QUERYSTRING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!