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.

Redirect non www to www or www to non www - 78Redirect non www to www or www to non www - 79Redirect non www to www or www to non www - 1Redirect non www to www or www to non www - 32Redirect non www to www or www to non www - 76Redirect non www to www or www to non www - 93Redirect non www to www or www to non www - 50Redirect non www to www or www to non www - 93Redirect non www to www or www to non www - 21Redirect non www to www or www to non www - 28Redirect non www to www or www to non www - 22Redirect non www to www or www to non www - 29Redirect non www to www or www to non www - 93Redirect non www to www or www to non www - 65Redirect non www to www or www to non www - 3Redirect non www to www or www to non www - 63Redirect non www to www or www to non www - 16Redirect non www to www or www to non www - 79Redirect non www to www or www to non www - 79Redirect non www to www or www to non www - 33Redirect non www to www or www to non www - 12Redirect non www to www or www to non www - 69Redirect non www to www or www to non www - 8Redirect non www to www or www to non www - 84