location / { if ($http_host !~ "m.xxx.cn"){ rewrite ^/web/(.*)/bdu(d?).htm(.*)$ /rewrite.php?custom_dir=$1&bdu_num=$2 last; } rewrite ^/seo_web/(.*)/index.html(.*)$ /seo_web/replace.php?custom_dir=$1; }