nginx下获取部分主机名

  • Post author:
  • Post category:IT
  • Post comments:0评论
server {
      listen          80;
      server_name     ^www.(?<domain>+)$;
      root            /var/www/htdocs/;
    if ($host ~* www\.(.*)) {
      set $host_without_www $1;
      }
      if ( $request ~ '/members' ) {
        rewrite ^(.*)$ http://member.$host_without_www/ permanent;
      }

}

发表评论