4 Ways To Redirect Or Troubleshoot Your Domain From Non-www To Www Or Www To Non-www

non www to www 768x768 1

Note: This post was migrated to GoodPassive.com

I was troubleshooting to find the root cause of the ERR_TOO_MANY_REDIRECTS. Basically, there is somewhere pointing to non-www or www at a place, and a setting to the opposite will cause a conflict. There are at least 4 ways I found that can set the redirects so you can check which of these may be causing the problem.

4 ways to redirect or troubleshoot your domain from non-www to www or www to non-www:

1. CDN provider i.e. Cloudflare (if the domain is connected to one)
2. Hosting provider redirection rule
3. .htaccess file
4. WordPress general settings

CDN provider

On your Cloudflare domain -> Rules, set up a rule to redirect for example:

Create Page Rule on Cloudflare
Hosting provider

For example, Hostinger Dashboard -> Redirects can create a redirection

Hostinger redirects create
.htaccess file

Edit the .htaccess file located under your hosting server main directory i.e. public_html by inserting these two lines under RewriteEngine On:

RewriteCond %{HTTP_HOST} ^judicioousquiz.com [NC]
RewriteRule ^(.*)$ http://www.judiciousquiz.com/$1 [L,R=301]

Remember to substitute judiciousquiz with your own domain name. You may find the original Hostinger article with images here. The redirection should take immediate effect.

WordPress general settings

Under WordPress Dashboard -> Settings -> General, enter the domain name URLs to be with or without www.

WordPress Settings General URLs

How may I know what is redirecting my domain from www to non-www?

From knowledgeable Cloudflare community support, a curl was done from the terminal to show that the redirection was on the hosting side. Start your terminal and type in this line and enter (replace example with your domain name);

$ curl -I https://www.example.com 

If you see a message like:

HTTP/1.1 301 Moved Permanently location: https://example.com/

and a line above this may indicate the redirection is done by WordPress.

How do I resolve ERR_TOO_MANY_REDIRECTS for my WordPress domain?

In my case, my domain only shows https://judiciousquiz.com without www and I am troubleshooting why setting a redirect to https://www.judiciousquiz.com kept resulting in ERR_TOO_MANY_REDIRECTS displayed on my page.

The solution is just a simple configuration of WordPress Settings->General and sets the domain URLs from non to www i.e. from https://judiciousquiz.com to https://www.judiciousquiz.com for both URLs.

WordPress General-> Settings for URL

To have www or not for a domain?

Based on what I read, it does not matter from an SEO perspective. Google treats both www and non-www as separate. I prefer to go with most sites adopting www.

How to enable SSL Full Strict from Cloudflare?

In my searches for a solution to resolve the error for too many redirects, the mentions of setting up a full SSL came up, even though my site is running on flexible SSL (not full). And from the free Cloudflare community support, I was advised to first get SSL Full (strict) set up first.

And unlike setting up flexible SSL which I have to wait for some hours before it stable down and works, setting to full without proper setup may result in an invalid certificate or something immediately.

Under your domain name in Cloudflare, navigate to SSL/TLS Overview, and select Full(strict). But the SSL should be imported and installed in your hosting server first (shown below).

Cloudflare SSL status

Note: SSL certificates from Cloudflare are free.

How to import the Cloudflare origin server SSL certificate in Hostinger?

On Cloudflare, navigate to your domain name, and SSL/TLS -> Origin Server. Click Create Certificate.

Cloudflare Origin Server Certificate Create

The default settings should look as shown, just select how long (longest is 15 years) for the certificate validity and click Create.

Cloudflare Origin Server Certificate Create

Simply copy and paste the original certificate and private key into Hostinger

Cloudflare Origin Server Certificate Created

Go to Hostinger-> SSL, click Import SSL, and paste the below accordingly the copied values from Cloudflare. You may leave CABUNDLE empty.

Paste Cloudflare Origin Server Certificate on Hostinger

The Hostinger SSL status should look somewhat as below.

How to test or clear your cache from your browser for domain issues?

From my experience, clearing cookies may not be necessary for these issues, however, these are the options.

  • Refresh browser page
  • Clear browsing data, including cookies
  • Chrome incognito mode
  • Another browser
  • VPN i.e. Kproxy
  • Purge cache i.e. WordPress LiteSpeed plugin

To see www in the domain if set up correctly, you may have to click the URL address in the address bar again depending on the browser.

Do I need to install a WordPress SSL plugin after Cloudflare or hosting server SSL installation?

Probably no need if you already installed the SSL on Cloudflare and/or the hosting server. In fact, the WordPress SSL plugin may acquire a different SSL certificate from Cloudflare or your hosting server.

Good Passive Logo

Sign up to receive Good Passive content in your inbox.

We don’t spam! Read our privacy policy for more info.

Leave a Reply

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security