Home  >  Q&A  >  body text

nginx - How to automatically resolve the pointing URL when creating a second-level domain name for a website?

Previous steps:

  1. Create a second-level domain name in dns
  2. Second-level domain name specifies A record binding
  3. Server binding second-level domain name

Current needs:

  1. The user creates the domain name xxx.example.com on the website
  2. Accessing this domain name automatically jumps to example.com/xxx
  3. How to implement this?
黄舟黄舟2712 days ago714

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 17:05:30

    Use pan-parsing processing. First, parse *.example.com to example.com, so that all subdomain names will point to example.com. Next, judge the request, take out the * part, and make the corresponding jump (for example, use $_SERVER['SERVER_NAME']).

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:05:30

    nginx should be able to do it, and it’s a good idea 0.0

    server{
        listen 80;
        server_name sec-domain.domain.com;
        location / {
            proxy_pass domain.com/sec-domain;
        }
    }
    

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 17:05:30

    1. Domain name pan-resolution
    2.apache uses mod_rewrite

    reply
    0
  • Cancelreply