简体   繁体   中英

How to Alias a Page to a Sub-Domain

I'm running WordPress on a LEMP stack.

I have a landing page at: https://example.com/landing

I want to point this subdomain at the above page: http://landing.example.com

I don't want to 301/302 redirect the subdomain to the subdirectory.

I want visitors to think they are still on http://landing.example.com .

This question is similar but doesn't solve my particular problem.

I need to know how to rewrite the request with nginx and configure DNS.

Link to previous post discussing rewrites/redirects/vhosts. You want to rewrite the request and then either land it on the same server or proxy it to a different one.

I found the answer in this thread .

To summarize, you need to proxy the request with nginx:

    # abc.example.com
    server {
      listen 80;
      server_name .example.com;
      location / {
        proxy_pass http://127.0.0.1/abc$request_uri;
        proxy_set_header Host example.com;
      }
    }

The just setup an A record pointing at your server's IP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM