nginx获取url参数
时间:2014-08-18 17:56:22
收藏:0
阅读:1952
在文件src\http\ngx_http_core_module.c的函数ngx_http_core_run_phases(ngx_http_request_t *r)里面,添加如下代码:
//声明部分 ngx_str_t* name; ngx_http_variable_value_t* val; char temp[15];
//实现部分 name=ngx_pnalloc(r->pool, sizeof(ngx_str_t)); name->data="arg_test"; name->len=sizeof("arg_test")-1; val=ngx_http_get_variable(r, name, 0); ZeroMemory(temp, sizeof(temp)); memcpy(temp, val->data, val->len); OutputDebugStringA(temp); OutputDebugStringA("\n");
如图:
运行nginx,在浏览器里输入:http://127.0.0.1/?test=beiJing
完。
原文:http://www.cnblogs.com/liyou-blog/p/3919926.html
评论(0)