正则表达式如何写呢?

2025-06-29 02:51:43
推荐回答(1个)
回答1:

rewrite ^/news-catid-([0-9]+)\.html$ /news.php?catid=$1;
rewrite ^/(.*)/news-catid-([0-9]+)\.html$ /$1/news.php?catid=$2;
合并为
rewrite ^/(.*)news-catid-([0-9]+)\.html$ (/$1)?/news.php?catid=($1|$2);
以下

rewrite ^/(.*)/category-catid-([0-9]+)\.html$ /$1/news.php?catid=$2;
rewrite ^/(.*)/category-catid-([0-9]+)-car_brand-([0-9a-z])\.html$ /$1/news.php?catid=$2&car_brand=$3;
合并为
rewrite ^/(.*)/category-catid-([0-9]+)(-car_brand-([0-9a-z]))?\.html$ /$1/news.php?catid=$2(&car_brand=$3)?;