Keep 'www' subdomain

I would like the URL of my domain to display as as opposed to (both in dev and prod).

Both sites redirect to by default. What’s the best way to ensure my site displays as And could you also briefly explain the reasoning behind removing the www?


Covered in the docs:

See www_redirect at

Thanks @ben, I should have looked more closely.

Looks like I just need to set www_redirect to false.

Any reason why the www is removed by default? Was there a best practice around this?

It’s a best practice to choose one or the other and force the redirect. Meaning either non-www or www should be the canonical domain and you should redirect to that one. The choice of non-www was our personal preference.

Got it. Thanks @swalkinshaw

Solved for development - but still trying to get the www subdomain working on production (DigitalOcean).

In development/wordpress_sites.yml, I added ‘www’ to site_hosts and set www_redirect to false. (I also updated manifest.json). “www” then worked once I ran vagrant reload --provision

I’m trying to get it working on my production domain, as well, with the same steps above. I’m not sure how to re-provision the production server, and wondering if this is a necessary step?

Otherwise, if I have taken all the right steps, it might be a setting in the digitalocean droplet domain that I need to update to get it working.

You can always ping the domain with www and make sure it resolves to the droplet address if you’re unsure.

Thanks, @cfx. It resolves. In the browser, it immediately redirects to the naked domain.

If helpful, attached are domain’s settings:

Ok good, where are you stuck now?

I’m trying to have the production site keep the www subdomain, but instead it keeps redirecting to the naked domain. I have it enabled in development (see above), but I had to re-provision the local server before it worked. Wondering if I have to do the same with the production server, as well?

I’m wondering the same thing :wink:

Any idea how to re-provision the production server? Locally, I just run vagrant reload --provision, but not sure how run this on production (server is on DigitalOcean).

Run the same command that you provisioned the server with.

Hi @ben,

First of all thanks for sharing Trellis publicly. I’m so grateful for that.

One thing about this project is annoying though. On the link you have shared about www_redirect, there is in fact no proper documentation about www_redirect. To be honest this part of Trellis is poorly documented and that brings these questions in my mind:

  1. If I have as my domain and I want the WP site to be served on, what should I put as the site_hosts? or
  2. How would that affect the functionality of letsencrypt as I would expect it to issue the certificates for both and

I would appreciate it if you help me with these questions.


To answer your questions:

  2. It already does that

We would appreciate it if you would take the time to dig into the code or just try things out yourself before asking for a hand.

1 Like

Hi guys,

After a lot of tests, it seem impossible to redirect all trafic of a domain to www.
If we add the www_redirect = False, both domains are accessible, it doesn’t act like a toggle.
I tried what @ben said in his last post. Is anyone found a solution for this ?
I’m currently trying to rewrite the default wordpress-site.conf so if anyone had a better solution let me know :slight_smile:

BTW, Thanks roots team for all the awesome setup !

Thanks @ben for your answers, I really appreciate that.

Without being rude, the thing that I do not understand and confuses me a lot is that why you think that Trellis configures the Nginx server blocks and issues letsencrypt certificates properly for a website which is supposed to be served on WWW. Because it doesn’t.

I have tried this several times with different versions of Trellis (including the last version as of now) and none of them worked properly. I have been waiting for this bug to be solved for a long time. I would have dived into the code to make a pull request much earlier if I knew any python to be honest.

I think I am going to learn a bit of Python to solve this issue now.

Thanks again for the precious work.

Hi @genzographics,

I had the same problem two weeks ago. You can solve this problem by yourself and you don’t have to code any line of python. You simply need to edit the wordpress-site.conf file in the wordpress-setup role. You can check my gist for a example. Note that I didn’t test it with multisite.


Trellis has changed much since this post so this may be due to a new version or another factor but:
Using a website that was in a traditional panel host and accessible at “www.”, I was able to achieve this in a move over to trellis simply by setting “www.” as the canonical, and then using the non-www domain as the redirect.
If I had to guess, it would be that having “www.” in the actual wordpress database options table definitely helps, though since so many had a problem I will safely chalk this up to the great devs at roots.

1 Like

Yeah, I’m closing this thread as the information/solutions in it are outdated.

Docs about hosts can be found at