Home  >  Q&A  >  body text

How does nginx correspond to resource files in different directories according to different subdomain names?

For example: a.example.com/index.html corresponds to /a-direcoty/index.html, while b.example.com/index.html Corresponds to /b-direcoty/index.html

黄舟黄舟2714 days ago659

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:14:52

    server {
    listen 80;
    server_name ~^(?<subdomain>.+).example.com$;
    index index.html index.htm;
    root /$subdomain-direcoty/;
    }

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 17:14:52

    nginx configuration file can set the server segment, and set server_name in the server to specify the domain name. So in this case, set up two servers, one with two domain names, and then set root as a specific directory

    reply
    0
  • Cancelreply