search

Home  >  Q&A  >  body text

nginx rewrite regular expression

http://localhost/action
http://localhost/action/pre/xx/xx

All action interfaces are handled by tomcat, but in order to access the two URLs above at the same time, I configured the following two location segments. I always feel that this configuration method is not very elegant. I would like to ask if there is a better way. Appreciate it!

location ~ ^/(action)/?$ {
    proxy_pass  http://tomcats;
}

location ~ ^/(action)/(.+)$ {
    proxy_pass  http://tomcats;
}
巴扎黑巴扎黑2831 days ago790

reply all(2)I'll reply

  • phpcn_u1646

    phpcn_u16462017-05-21 18:59:24

    Hello, may I ask what the original address of

    thinkPHP3.2 message board video tutorial

    is? I want to research it.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-19 10:50:22

    Depend on your needs and requirements directly

    location ^~ /action/{
        proxy_pass  http://tomcats;
    }

    That should be enough.

    reply
    0
  • Cancelreply