How to configure nginx to configure domain names for each subdirectory in a virtual host?
高洛峰
高洛峰 2017-05-16 17:28:28
0
1
631

How to configure nginx to configure domain names for each subdirectory in a virtual host?
The requirement is that two directories, home and admin
, are placed in a virtual host. Home binding home.xx.com
admin binds admin.xx.com
I don’t want to create two virtual hosts.

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
phpcn_u1582
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;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template