How to change non-www to www in CentminMod

by Daniel Pham
Published: Updated:

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

change non-www to www for website 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 www.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 www.systemmen.com;

Change it to.

#x# HTTPS-DEFAULT
 server {

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

server {
  listen 443 ssl http2;
  server_name systemmen.com www.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://devopslite.com. Hope this article helpful for you.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.