Best way to add a 301 redirect

Could anyone help me with adding a 301 redirect to Discourse.

I would like to redirect www to non-www. I also have sub-domains too.

I have read in someplaces that I need to add a line of code to nginX but I am not really sure how to do this.

I have also been told that I can do this using cloudflare too.

What is the best option and how would I go about doing this please.

Thank you in advance.

One way is Setting up Let’s Encrypt with Multiple Domains.


Thank you for your help. If I buy and I stall wildcard SSL cert would this also do the same job?


Yes, but it will be at least as hard to configure, and you’ll have to remember how to do it every time it expires.