nginx - How to automatically resolve the pointing URL when creating a second-level domain name for a website?
黄舟
黄舟 2017-05-16 17:03:30
0
3
774

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?
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
phpcn_u1582

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']).

曾经蜡笔没有小新

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;
    }
}
phpcn_u1582

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template