• 请不要在回答技术问题时复制粘贴 AI 生成的内容
daijinming
V2EX  ›  程序员

URL 重写 正则表达式求教

  •  
  •   daijinming · Mar 18, 2019 · 2168 views
    This topic created in 2689 days ago, the information mentioned may be changed or developed.

    原始地址:demo.com/_/app1/index.html ,重写后客户端看到的网址:demo.com/_app1/index.html, 如果要达到这样的重写效果,不知道正则表达式怎么写

    4 replies    2019-03-18 18:57:47 +08:00
    sparkssssssss
        1
    sparkssssssss  
       Mar 18, 2019
    rewrite ^/([^/]+)/([^/]+)/(.*) /$1$2/$3 break;
    daijinming
        2
    daijinming  
    OP
       Mar 18, 2019
    @coolloves 感谢,但是这个好像对静态资源不管用,估计只对控制器有作用
    imlinhanchao
        3
    imlinhanchao  
       Mar 18, 2019   ❤️ 1
    @daijinming 静态资源可以在 Nginx 做
    TomVista
        4
    TomVista  
       Mar 18, 2019   ❤️ 1
    global.asax
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
    if (Context.Request.FilePath == "/") Context.Request.rewrite(" something")
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3201 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:56 · PVG 20:56 · LAX 05:56 · JFK 08:56
    ♥ Do have faith in what you're doing.