
应用场景:
http://zzl.lteam.cn/ 访问/usr/local/boke/lteam.cn/zzl 目录下的 index.html
http://lj.lteam.cn/ 访问/usr/local/boke/lteam.cn/lj 目录下的 index.html
目录结构:
/usr/local/boke/
├── lteam.cn
│ └── zzl
│ ├── index.html
│ └── lj
│ ├── index.html
nginx配置:
server {
listen 80;
server_name *.lteam.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
if ($host ~* ^([^\.]+)\.([^\.]+\.[^\.]+)$) {
set $subdomain $1;
set $domain $2;
}
location / {
# root html;
# index index.html index.htm;
root /usr/local/boke/$domain/$subdomain;
index index.html;
}
}
文章来源: nginx将泛解析的匹配域名绑定到子目录配置方法
人吐槽 | 人点赞 |
发表评论