V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sophymax
V2EX  ›  程序员

有个静态文件,文件名是 aaaa?c=21&d=89 ,在 nginx 里访问的话它会去请求 aaaa 这个文件,结果自然是 404,请问如何处理才能直接访问 aaaa?c=21&d=89 这个文件,rewrite 吗?怎么写这种?

  •  
  •   sophymax · 2014-08-09 19:35:03 +08:00 · 2419 次点击
    这是一个创建于 3561 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2014-08-09 21:11:54 +08:00
    谢谢各位的提示,rewrite方式是在太蛋疼了,最终解决方案如下(其实想做的是把asp的网站以全静态的方式copy出来,参见上一篇帖子),使用nginx的第三方插件HttpLuaModule:
    rewrite_by_lua '
    if string.find(ngx.var.uri,".asp")~=nil then
    if ngx.var.args~=nil then
    ngx.req.set_uri(ngx.var.uri.."?"..ngx.var.args)

    else
    ngx.req.set_uri(ngx.var.uri)
    end
    end
    ';
    nginx原生rewrite太不熟悉了,直接用rewrite怎么写,有人会写吗?
    2 条回复    2014-08-09 19:47:16 +08:00
    rio
        1
    rio  
       2014-08-09 19:46:55 +08:00   ❤️ 1
    搜索关键词是 percent-encoding 和 URL reserved characters
    minbaby
        2
    minbaby  
       2014-08-09 19:47:16 +08:00   ❤️ 1
    转义 aaaa%3Fc%3D21%26d%3D89
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1381 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:45 · PVG 01:45 · LAX 10:45 · JFK 13:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.