Home  >  Q&A  >  body text

How does nginx forward all requests to a domain name?

My nginx is bound to several domain names, but I want these domain names to be used as aliases, and all incoming requests will be forwarded to my main domain name
Currently, I can only configure multiple servers. How should I configure nginx to transfer to a domain name?

PHP中文网PHP中文网2683 days ago732

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-05-16 17:31:51

    oneserver 绑定多个域名 : server_name www.fb.com ta.fb.com c.fb.com
    jump

    if ($host !~* ^www\.fb\.com$)
        {
            rewrite ^/(.*)$ http://www.fb.com/ redirect;
        }    
    

    I haven’t configured it for more than a year, so I don’t know if it’s correct, haha, that’s probably the idea

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 17:31:51

    server_name www.a.com www.b.com www.c.com ;

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:31:51

    Specially, register an account. Tell everyone. There is a semicolon missing on the first floor; hahahahaha after the redirect

    reply
    0
  • Cancelreply