问题描述
nginx在一个虚拟主机里面给各个子目录配置域名如何配置呢?需求是一个虚拟主机里放了两个目录home和adminhome绑定home.xx.comadmin绑定admin.xx.com不想做成两个虚拟主机.
问题解答
回答1:server { listen 80; server_name *.xx.com; # set a default root set $rootdir /home/xx/public_html; # try if is a subdomain if ($host ~* ^(.+).xx.com$) {set $rootdir /home/xx/subdomains/$1; } root $rootdir;}