To make your domain listen on www.example.com instead of example.com you have to do the following steps.
Before we continue, we can start off with advising you that you can also create the domain in Ploi prefixed with www already, Ploi is smart enough to detect this and setup all the configuration properly. For example, if you have a domain called examplehosting.com and you want to have it forced to www.examplehosting.com, just create it as that domain. Ploi will automatically detect this and setup the non-www to be redirected to the www version.
If you have an already existing domain in your server follow these steps:
(Make sure you replace example.com with your own domain)
- Change the
server_name
variable inside your NGINX config. You can find this config file in this path (or you can use our UI to edit): /etc/nginx/sites-available/example.com - (Optional): If you have SSL enabled, you will have to edit the redirect too. Open up this file: /etc/nginx/ploi/example.com/before/ssl-redirect.conf and edit these lines:
server_name example.com
TO
server_name www.example.com
And
return 301 https://example.com$request_uri;
TO
return 301 https://www.$host$request_uri;
3. After this, save these files and restart NGINX.