Nginx泛解析之后匹配域名绑定到子目录并区配目录名为域名
# tree /home/wwwroot/dnwfb.com
/home/wwwroot/dnwfb.com
├── blog
│ └── index.html
└── file
└── index.html
/home/wwwroot/dnwfb.com为nginx的安装目录下默认的存放源代码的路径。
blog为博客程序源代码路径
file为附件路径
把相应程序放入上面的路径通过
http://blog.dnwfb.com 访问博客
http://file.dnwfb.com 访问附件
其它二级域名类推。
方法一:
方法二:server {
listen 80;
server_name ~^(?<subdomain>.+).dnwfb.com$;
access_log /data/wwwlogs/dnwfb.com_nginx.log combined;
index index.html index.htm index.php;
root /home/wwwroot/dnwfb.com/$subdomain/;
}
server {
listen 80;
server_name *.dnwfb.com;
access_log /home/wwwlogs/dnwfb.com.log combined;
index index.html index.htm index.php;
if ($host ~* ^([^/.]+)/.([^/.]+/.[^/.]+)$) {
set $subdomain $1;
set $domain $2;
}
location / {
root /home/wwwroot/dnwfb.com/$subdomain/;
index index.php index.html index.htm;
}
}
声明
源码下载不顺利,比如源码在百度网盘的有时会被无故取消等,请联系QQ:46667551
本站大部分下载资源收集于网络,但除特别说明之外,基本全部亲自测试可用!
但由于某些源码的更新迭代,比如微信小程序官方接口的变动等原因,
如时间过长,可能会造成本可以使用的代码出现问题,下载前请斟酌!
本站资源仅供学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除。
若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。
原文链接:https://www.dnwfb.com/244.html,转载请注明出处