Prevent double redirects

ssl
https

#1

On my website, I just setup the Cloudflare. But I have some issues, I read some similar treads but probably mine is a bit different and I need some help.
This is what I get in speed tests: http://prntscr.com/kblzso

In my .htaccess file I have this:
First I want to avoid www from the url:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]

then I want my open a subpage directly when accessing the domain and I make another redirect.
Redirect 301 /index.html https://cultureastrology.com/zodiac-signs/

But I noticed that this has bad effect and it slows my website, so I want to avoid this.
If you access on all this urls:
www.cultureastrology.com
cultureastrology.com
http://cultureastrology.com

all need to open https://cultureastrology.com/zodiac-signs/

Any suggestions what I need to do?

Thanks


#2

Add a Cloudflare Page Rule:
Match: *cultureastrology.com/ and URL Forward (code 301) it to: https://cultureastrology.com/zodiac-signs/

The Cloudflare Crypto setting for “Always Use HTTPS” might inject an HTTPS redirect before hitting the Page Rule. If so, turn that feature off and add a second Page Rule:
Match cultureastrology.com/ and set it to “Always Use HTTPS”

The first rule will catch any combination of http/https or www/non-www to your root directory and send them to the HTTPS subdirectory. The second rule will catch anybody not using HTTPS and turn it on. The first rule takes priority, so those visitors won’t get the second rule’s HTTPS redirect, as Rule #1 adds HTTPS.


#3

Tnx @sdayman I have a progress. I remove all the rules in the .htaccess and add yours.

Now only this is not good … when I want to access the site on this way: www.cultureastrology.com/zodiac-signs/
it redirects to https://www.cultureastrology.com/zodiac-signs/
so www is not ommited here.

Any suggestion for this?


#4

Are people actually typing in www and the path? That sounds like an edge case. You would be much better off if you just fixed your site’s directory structure.

You can use .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.cultureastrology.com$ [NC]
RewriteRule ^(.*)$ https://cultureastrology.com/$1 [R=301,L]

Or another page rule that matches www.cultureastrology.com/zodiac-signs/* and redirects to https://cultureastrology.com/zodiac-signs/$1
Make this Rule #2 and that Always Use HTTPS as Rule 3


#5

Hi @sdayman I just noticed one more thing … If I access some page for ex. cultureastrology.com/zodiac-signs/virgo/ it is not changing to https, and if you continue navigate through the website, all pages are without https. Is it possible to fix this?