最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Nginx泛解析的匹配域名绑定到子目录配置的例子
时间:2022-06-30 18:29:48 编辑:袖梨 来源:一聚教程网
网站的目录结构为:
# tree /home/wwwroot/111com.net
/home/wwwroot/111com.net
├── blog
│ └── index.html
└── file
└── index.html
/home/wwwroot/111com.net为nginx的安装目录下默认的存放源代码的路径。
blog为博客程序源代码路径
file为附件路径
把相应程序放入上面的路径通过
http://blog.111com.net 访问博客
http://file.111com.net 访问附件
其它二级域名类推。
方法一:
server {
listen 80;
server_name ~^(?
access_log /data/wwwlogs/111com.net_nginx.log combined;
index index.html index.htm index.php;
root /home/wwwroot/111com.net/$subdomain/;
...
}
方法二:
server {
listen 80;
server_name *.111com.net;
access_log /home/wwwlogs/111com.net.log combined;
index index.html index.htm index.php;
if ($host ~* ^([^.]+).([^.]+.[^.]+)$) {
set $subdomain $1;
set $domain $2;
}
location / {
root /home/wwwroot/111com.net/$subdomain/;
index index.php index.html index.htm;
}
...
}
``
相关文章
- 《1号会员店》关闭自动续费方法 01-29
- 《排球少年:新的征程》社团每日福利领取方法 01-29
- 《椿之歌》新手风属性队伍推荐 01-29
- 《最终幻想14:水晶世界》小小阿托莫斯宠物获得方法 01-29
- 《燕云十六声》醉拳客打法攻略 01-29
- 《异人之下》全货币获取方法汇总 01-29