Let's encrypt and non-www to www redirect

How do I set a redirect non-www to www if Let’s encrypt enabled?

server { listen 80; server_name domain.com; return 301 https://www.domain.com$request_uri; }

in /sites-available/domain.com did not work.

K.

go to /etc/nginx/conf.d/force-ssl-yoursitedomain.com.conf and past your code there above the already existing server {

Make sure you test nginx after saving with nginx -t

1 Like

Does this work as of today ?