How to redirect one subdomain to one specific page when another subdomain is the main domain

I have a website with two subdomain:

I would like to redirect othersubdomain.site.com to mainsubdomain.site.com/repertory with this config

wordpress_sites:
  site:
site_hosts:
  - canonical: mainsubdomain.site.com
  - canonical: othersubdomain.site.com
local_path: ../site
repo: git@github.com:site.git
repo_subtree_path: site
branch: master
multisite:
  enabled: false
ssl:
  enabled: true
  provider: letsencrypt
  hsts_max_age: 31536000
  hsts_include_subdomains: false
  hsts_preload: true
cache:
  enabled: true

The two domains use ssl and letsencrypt. I tested a lot of things but everytime the domain othersubdomain.site.com redirect to mainsubdomain.site.com. Even when I remove othersubdomain.site.com to the canonical list… I tested every 301 redirection possible in the nginx conf directly without success.

Any ideas ?

There’s a redirects key you could use to do this. Check out the docs for more info.
Give that a try and see how you get on.

Maybe I miss understood but redirects will only redirect domains to the main domain right ?

Yes that’s correct. I guess you have two options:

  1. Use a redirect in WP (there’s lots of plugins for this)
  2. Use the Nginx includes feature in Trellis. It even discusses the rewrites use case.

This topic was automatically closed after 42 days. New replies are no longer allowed.