我想要这个功能:
mydomain.com--->301--->mynewdomain.com
subdomain1.mydomain.com--->301--->subdomain1.mynewdomain.com
subdomain2.mydomain.com--->301--->subdomain2.mynewdomain.com
...............
subdomain*.mydomain.com--->301--->subdomain*.mynewdomain.com所以谁能给我一些nginx配置代码。我试过了,但没有用:
server{
listen 80;
server_name "~^(.*)mydomain.com";
set $sub_name $1;
return 301 $scheme://{$sub_name}mynewdomain.com$request_uri ;
}发布于 2018-09-30 13:52:40
您应该在server_name正则表达式中使用命名捕获。详情请参见本文件。
如果变量名需要大括号,请使用${ ... }。
例如:
server{
listen 80;
server_name ~^(?<sub_name>.*)mydomain.com;
return 301 $scheme://${sub_name}mynewdomain.com$request_uri;
}https://stackoverflow.com/questions/52577903
复制相似问题