问题原文
原帖链接 · Tristan · CC BY-SA 3.0
I'd like to redirect all traffic from
www.*.*.<gTLD>
to
*.*.<gTLD>
If possible, I'd like to do that outside the block that serves the application. This block does not use a server_name because it listens to 5,000+ hostnames on the same app.
Do you have an idea on how to achieve that please ? All the example I find is only for named hosts....
Thank you
已采纳解答
原帖链接 · Richard Smith · CC BY-SA 3.0
You can define a server block with a regular expression server_name. For example:
server {
server_name ~^(www\.)(?<domain>.+)$;
return 301 $scheme://$domain;
}
See this document for more.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
