Nginx配置 批量二级域名映射到二级目录
这里是使用正则表达式配置,对www与@有额外配置。
server {
listen 80;
server_name www.miqie.net miqie.net;
root /app/dexun/vip/xiaozhan;
location / {
root /app/dexun/vip/xiaozhan;
index index.html;
}
}
server {
listen 80;
server_name *.miqie.net;
if ( $host ~* (.*)\.(.*)\.(.*)){
set $domain $1;
}
root /app/dexun/vip/$domain;
location / {
root /app/dexun/vip/$domain;
index index.html;
}
}