search

Home  >  Q&A  >  body text

rewrite - How can nginx rewrite certain routes?

For example, if I want to rewrite the following route:
/user?id=55
/question
to /dispatch, how should I write it?

伊谢尔伦伊谢尔伦2755 days ago471

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 17:15:34

    location /question/ {
        rewrite ^/question(.*) /dispatch$1 last;
    }
    
    location /user/ {
        if ($query_string = "id=55") {
            rewrite ^/user(.*) /dispatch$1 last;
        }
        
    }
    

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 17:15:34

    location /question/ {

    rewrite ^/question(.*) /dispatch$1 last;

    }

    location /user/ {

    if ($query_string = "id=55") {
        rewrite ^/user(.*) /dispatch$1 last;
    }
    

    }

    reply
    0
  • Cancelreply