It creates a duplicate entry, which is not suitable for SEO. I noticed this when I analyzed my site with an SEO tool, thought to share it with you all. There are many ways to redirect non-www to www or www to non-www. Let’s look at some of the easiest ways to get this done.
Apache HTTP
If you are using an Apache HTTP server then you may either achieve this redirection through .htaccess or by modifying httpd.conf file. If you are on shared hosting then you may prefer doing .htaccess file but if you have full control on servers like VPS or Cloud then worth considering httpd.conf way. Whatever method you choose, take a backup of the file before modifying anything. To redirect from www to non-www, you can add the following. And, to redirect from non-www to www, add the below. Save the file and restart Apache if used httpd.conf method.
Nginx
To redirect from www in Nginx, you can add the following code in nginx.conf file under server block. The following example is for redirecting from www to non-www. And, below code is for redirecting from www to non-www. Save the file and restart Nginx server.
Cloudflare
Implementing redirection is very easy if you are using Cloudflare. You can take advantage of Page Rules to implement redirection.
Log in to Cloudflare and select the site where you want to put the redirection Go to the Page Rules tab and create a new rule Enter the URL and select setting as “Forwarding URL” Select the status code (301 if you want it permanently) Enter the target where you want to redirect The following rule is to redirect everything from https://www.geekflare.com to https://geekflare.com
Once done, click Save and Deploy
And within a minute, your site redirection is live.
Conclusion
I hope the above helps you to put the redirection as you want. If you are using WordPress and looking to redirect more than www then check out this article to handle redirection in WP.