1. 程式人生 > >nginx將泛解析的匹配域名繫結到子目錄配置方法

nginx將泛解析的匹配域名繫結到子目錄配置方法

應用場景:

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; } }