1

I am getting this error for redirect chain on GTMetrix when I check my website.

The chain is as follows:

http://
https://
https://www.

I am using this plugin for HTTPS

https://wordpress.org/plugins/wordpress-https

In the plugin I have configured the address to not have anything prior to the domain name. No http, https, or www.

I use CloudFlare flexible SSL

https://wordpress.org/plugins/cloudflare-flexible-ssl/

Along with my cloudflare settings, I have a cname record for "www" which points to my domain. An A record for my domain name which points to my dedicated server IP address.

I have a single page rule for http://domain.com/* which is set to "Always Use HTTPS"

In the Crypto tab I have enabled "Always Use HTTPS".

I have a GTMetrix score of 100% when I input "www" before the domain. This "Avoid Landing Page Redirects" error occurs only when putting http:// at the beginning. It drops my points by 10% on PageSpeed, as well 11% of YSlow Score so it is still a pretty big difference having the latency of this redirect chain.

I have both my 'WP_HOME' and 'WP_SITEURL' set to 'https://www'

This is because when I try setting to anything other than this, it will not allow me access to my website. I try removing the www from both, or even just one of them, no matter which I try I will end up with my site being inaccessible.

My .htaccess is not modified it is the one you will find here.

https://codex.wordpress.org/htaccess

I have tried disabling plugins, seeing if anything is direct cause, but came to no fix. Every source I find related to this genuinely seems like it could solve my issue.. but I try many things only to have no luck.

I am certain this is a simple error, mistake on my behalf which I am overlooking.

Due to my non-disclosure agreement of this project, I am unable to share any GTMetrix scans or the URL for further inspection. I apologize for this, I hope this does not cause issues with trying to solve the redirect chain.

Thank you for taking the time to read, if you are able to help me in any way it would be much appreciated. If any further information is required please do let me know!

2
  • Remove all these plugins and do the redirections correctly with htaccess. And never use plugins for SSL - most of the time they don’t fix the configuration but mask the errors - and that’s why you get such problems later on. Mar 28, 2019 at 6:32
  • first things first. Get rid of CloudFlare and check and simplify your config. Only then add CF. Otherwise it’s like playing jenga ;) Mar 28, 2019 at 6:40

1 Answer 1

1

I would approach it like so:

  1. Remove all of these plugins.
  2. Decide if you want to use the address with or without www. prefix as default.
  3. Install SSL correctly, without a plugin. (So change all of the URLs in database and make sure your site works correctly, its address is set properly and there is no redirection when you go to your default address from 2.)
  4. Add .htaccess redirection from HTTP -> HTTPS
  5. Add .htaccess redirection from www.example.com -> https://example.com (or from example.com to https://www.example.com - depends on what you've decided in 2.)
  6. Configure CloudFlare correctly using the correct address from 2.

This way you should get always only one redirection.

2
  • I would like to do exactly what @Drozdz suggests -- add .htaccess redirection from www.example.com to example.com. But if you do this ,what happens when the user types in an http:// in front of example.com?
    – user163862
    Jun 30, 2020 at 23:49
  • He gets redirected to example.com you have to take care of all such cases in the .htaccess file Jul 2, 2020 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.