Heim  >  Fragen und Antworten  >  Hauptteil

rewrite – Wie kann Nginx bestimmte Routen umschreiben?

Wenn ich zum Beispiel die folgende Route umschreiben möchte:
/user?id=55
/question
to /dispatch, wie soll ich sie schreiben?

伊谢尔伦伊谢尔伦2713 Tage vor435

Antworte allen(2)Ich werde antworten

  • 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;
        }
        
    }
    

    Antwort
    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;
    }
    

    }

    Antwort
    0
  • StornierenAntwort