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

**URL:** https://discourse.roots.io/t/how-to-redirect-one-subdomain-to-one-specific-page-when-another-subdomain-is-the-main-domain/15042
**Category:** trellis
**Tags:** nginx
**Created:** 2019-03-11T12:43:25Z
**Posts:** 5

## Post 1 by @julianfox — 2019-03-11T12:43:25Z

I have a website with two subdomain:

- [mainsubdomain.site.com](http://mainsubdomain.site.com)
- [othersubdomain.site.com](http://othersubdomain.site.com)

I would like to redirect [othersubdomain.site.com](http://othersubdomain.site.com) to [mainsubdomain.site.com/repertory](http://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](http://othersubdomain.site.com) redirect to [mainsubdomain.site.com](http://mainsubdomain.site.com). Even when I remove [othersubdomain.site.com](http://othersubdomain.site.com) to the canonical list… I tested every 301 redirection possible in the nginx conf directly without success.

Any ideas ?

---

## Post 2 by @codepuncher — 2019-03-11T18:08:44Z

There’s a `redirects` key you could use to do this. Check out the [docs](https://roots.io/trellis/docs/wordpress-sites/#options) for more info.  
Give that a try and see how you get on.

---

## Post 3 by @julianfox — 2019-03-12T02:58:53Z

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

---

## Post 4 by @swalkinshaw — 2019-03-14T00:23:01Z

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](https://roots.io/trellis/docs/nginx-includes/) feature in Trellis. It even discusses the rewrites use case.

---

## Post 5 by @system — 2019-04-22T12:43:25Z

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