nginx的url重写实战

Rewrite语法

Rewrite 正则表达式  定向后的位置 模式

 

Goods-3.html ---->Goods.php?goods_id=3

goods-([\d]+)\.html ---> goods.php?goods_id =$1  

 

location /ecshop {

    index index.php;


    rewrite goods-([\d]+)\.html$ /ecshop/goods.php?id=$1;


    rewrite article-([\d]+)\.html$ /ecshop/article.php?id=$1;


    rewrite category-(\d+)-b(\d+)\.html /ecshop/category.php?id=$1&brand=$2;

 

    rewrite category-(\d+)-b(\d+)-min(\d+)-max(\d+)-attr([\d\.]+)\.html /ecshop/category.php?    id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5;

 

    rewrite category-(\d+)-b(\d+)-min(\d+)-max(\d+)-attr([\d+\.])-(\d+)-([^-]+)-([^-]+)\.html /ecshop/category.php?    id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8;

}

 

例子:

nginx的url重写实战


注意:用url重写时, 正则里如果有”{}”,正则要用双引号包起来

nginx的url重写实战

(将复杂的放前面匹配,防止遇到中文各种乱码字符的问题)

上一篇:ECSHOP修改100条


下一篇:ECSHOP快递单号查询插件圆通V8.2专版