实例:regex.conf
118.24.25.216 en.kf0001.mb.mxs223.com
118.24.25.216 en.kf0001.mb.mxs223.com
118.24.25.216 kf0001.mb.mxs223.com
118.24.25.216 en-kf0001-mb.mxs223.com
en.kf0001.mb.mxs223.com:8080
注意正则匹配顺序,如果第一个server 在第二个 server后面,则 en.kf0001.mb.mxs223.com无法进入第一个server
#第一个server
# en.kf0001.mb.mxs223.com 跳转到 en-kf0001-mb.mxs223.com
server{
listen 80;
server_name ~^(?<language>en|tcn|jap|kor|lo|th|es|ru|fra|it|de)\.(?<domain>.+)(\.mb).mxs223.com$;
location /{
rewrite ^/(.*) https://$language-$domain-mb.mxs223.com/$1 permanent;
}
}
#第二个server
# kf0001.mb.mxs223.com 跳转到 kf0001-mb.mxs223.com
server{
listen 80;
server_name ~^(?<domain>.+)(\.mb).mxs223.com$;
location /{
rewrite ^/(.*) https://$domain-mb.mxs223.com/$1 permanent;
}
}