I currently have two A records setup on Cloudflare DNS screen:
- “groundthumpinmotors.com” pointing to my groundthumpinmotors.com IP address
- “www” pointing to the same groundthumpinmotors.com IP address
Also in Cloudflare, I also have SSL set to “Full Strict” and also have turned on “Always use HTTPS”.
Next, in my Cpanel redirect section, I have set up so that my htaccess has the following in it now:
RewriteCond %{HTTP_HOST} ^groundthumpingmotors.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.groundthumpingmotors.com$
RewriteRule ^(.)$ “https://groundthumpinmotors.com/$1” [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^groundthumpinmotors.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.groundthumpinmotors.com$
RewriteRule ^(.)$ “https://groundthumpinmotors.com/$1” [R=301,L]
The results of the above are almost perfect except for one issue. Below is what I am getting:
groundthumpinmotors.com → https://groundthumpinmotors.com = CORRECT
groundthumpingmotors.com → https://groundthumpinmotors.com = CORRECT
www.groundthumpingmotors.com → https://groundthumpinmotors.com = CORRECT (This one does remove www like it should)
www.groundthumpinmotors.com → https://www.groundthumpinmotors.com = NOT CORRECT (does NOT remove the www like it should)
I am not understanding why if the user adds the www in front of groundthumpinmotors.com, the redirect is not removing the www, and instead it is leaving it in place. When doing the same thing to my 2nd domain name, with the (g) in the domain name, it does work properly.
What am I missing here? How do I make this work?
Also, btw, if I am turning things on in Cloudflare that are unnecessary or redundant, please let me know. Also, if I am adding htaccess code that is unnecessary, please let me know.
PS - For testing, I have added a Cloudflare page rule specifically to redirect www.groundthumpinmotors.com to https://groundthumpinmotors.com and it does work, but why am I having to do this in the first place. It is wasting a page rule of which I only have 2, so rather not waste it on this issue.
Thanks in advance for any help you can provide on this. Take care everyone!