Nginx redirect from domain.tld to www

Hi,

I have a WordPress site and I would need to redirect domain.tld to www.domain.tld.

In the Nginx template I have as server_name domain.tld
I tried to add a redirect with return 301 http://www.domain.tld$request_uri; but instead of opening the home page it opens the default “Success your new web server is ready to use”…

Am I missing something?

Make sure you add www.domain.com as alias and then enable redirect function

1 Like