How to redirect from https://www.mywebsite.com to https://mywebsite.com

How can I redirect from/between https://www.mywebsite.com to/and https://mywebsite.com

My domain registrar is Porkbun and I host it on Sourcehut.

My website works with https://mywebsite.com but it does not work with https://www.mywebsite.com and gives following error:

An error occurred during a connection to www.dostoynikov.com. Peer reports it experienced an internal error. Error code: SSL_ERROR_INTERNAL_ERROR_ALERT The page you are trying to view cannot be shown because the authenticity of the received data could not be verified. Please contact the website owners to inform them of this problem.

How is that related to Hugo? You should talk to the people running your web server and ask them how to redirect or rewrite URLs. Or have your domain registrar point mywebsite.com to www.mywebsite.com or vice versa.

I do not know with what it related so that’s why I asked. I thought maybe there is a way to add both to the baseUrl so that we can have both. I’m still learning how it works.

There’s not. It is a singular baseURL.

This is a DNS / Registrar problem / question.

You should go on your registrar page.
And set a new rule that redirects traffic as you want to.

There aren’t any Hugo settings that would help you with this.

Thanks. I did the DNS and urlForwarding settings on Porkbun side but it did not work. I just sent them a mail to proceed with the solution.

have a look at their documentation, you might just have missed something :