Redirect Subdomain to Specific Page

aka: Someone please walk me through nginx-includes :frowning:

I need to setup a subdomain on a Trellis site, and loading that subdomain needs to redirect to a specific URL. Like:

sale.example.com => example.com/complex-url-super-sale/


I’ve first added a canonical URL for the subdomain into wordpress_sites.yml (so that loading the subdomain doesn’t give an SSL error).

      - canonical: example.com
        redirects:
          - www.example.com
      - canonical: sale.example.com

Next I’ve created a file nginx-includes/subdomains.conf.site.j2 which contains:

server {
    listen 80;
    server_name sale.example.com;
    location / {
        proxy_pass https://example.com/complex-url-super-sale/;
    }
}

…and this file makes it to the server. But, loading the subdomain just redirects to the home page. So I’m guessing this file is being ignored?

Help appreciated :smiley:

2 Likes

I have the same issue, the subdomain is always redirect to the main domain… Even when I write the config directly in the main config file

1 Like