实例: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

  1. #第一个server
  2. # en.kf0001.mb.mxs223.com 跳转到 en-kf0001-mb.mxs223.com
  3. server{
  4. listen 80;
  5. server_name ~^(?<language>en|tcn|jap|kor|lo|th|es|ru|fra|it|de)\.(?<domain>.+)(\.mb).mxs223.com$;
  6. location /{
  7. rewrite ^/(.*) https://$language-$domain-mb.mxs223.com/$1 permanent;
  8. }
  9. }
  10. #第二个server
  11. # kf0001.mb.mxs223.com 跳转到 kf0001-mb.mxs223.com
  12. server{
  13. listen 80;
  14. server_name ~^(?<domain>.+)(\.mb).mxs223.com$;
  15. location /{
  16. rewrite ^/(.*) https://$domain-mb.mxs223.com/$1 permanent;
  17. }
  18. }