How to change non-www to www in CentminMod


SystemMen - How to change non-www to www in CentminMod? During the operation of my blogs, I may have to move them several times between servers. Due to financial problems or internet speed problems.

If your website is running https://www.yourwebsite.com and when you change server to CentminMod, it is changed to https://yourwebsite.com. What will you do?

By default, when you create a WordPress website, it will configure your website to run non-www.

Change non-www to www for the website in CentminMod

how-to-change-non-www-to-www-in-centminmod How to change non-www to www in CentminMod
Change non-www to www for website in CentminMod.

For example, my website, systemmen.com. You will need to open the vhost configuration file for this website, with the following command.

Replace your domain in the command below.

nano /usr/local/nginx/conf/conf.d/systemmen.com.ssl.conf

Then you look to this paragraph.

#x# HTTPS-DEFAULT
 server {

   server_name systemmen.com systemmen.com;
   return 302 https://systemmen.com$request_uri;
   include /usr/local/nginx/conf/staticfiles.conf;
 }

server {
  listen 443 ssl http2;
  server_name systemmen.com systemmen.com;

Change it to.

#x# HTTPS-DEFAULT
 server {

   server_name systemmen.com systemmen.com;
   return 301 https://systemmen.com$request_uri;
   include /usr/local/nginx/conf/staticfiles.conf;
 }

server {
  listen 443 ssl http2;
  server_name systemmen.com systemmen.com;

And then reload the Nginx service. Here, you do not need to restart the Nginx service to prevent unnecessary downtime for other websites.

service nginx reload

To be sure, you can open the terminal and type the following command to check if your website has been redirected to www.

curl -I http://yourwebsite.com

The result.

HTTP/1.1 301 Moved Permanently
Date: Tue, 30 Jul 2019 09:42:40 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://www.yourwebsite.com/
Server: nginx centminmod
X-Powered-By: centminmod

You need to pay attention to the line.

HTTP/1.1 301 Moved Permanently

That line shows that you have successfully configured www for your website. if you get the 200 code returned, that is the configuration you failed.

Conclusion

It’s just a small trick, but it can help your website run www as you wish. For example, my website will be https://systemmen.com. Hope this article helpful for you.

«« »»