两个php参数的nginx重写规则

时间:2015-08-09 04:55:42

标签: regex linux apache nginx system-administration

请帮我写一下ngnix的重写规则:

    Actual URL : http://www.example.com/all-dog-breeds.php?Greater-Swiss-Mountain-Dog/82



   expected URL : http://www.example.com/Greater-Swiss-Mountain-Dog/82

我尝试了下面的重写网址,但它无效:

   rewrite ^/([A-Za-z-]+)\/([0-9]+)\/?$ /all-dog-breeds.php?$1/$2;

   rewrite ^/(.*)/(.*)$ /all-dog-breeds.php?$1/$2 last; 

1 个答案:

答案 0 :(得分:0)

您实际需要的正则表达式为:https://regex101.com/r/uC1wH6/3

我认为应该按照以下方式转换为Apache:

rewrite ^\/[^\/]*\?(.*)$ /$1