网站的目录结构为:
# 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/;
}
方法二:
本文链接:https://www.dnwfb.com/244.html,转载请注明出处。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;
}}
评论0