The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Intermediate & Advanced SEO
    4. Redirect chains from switch to HTTPS

    Redirect chains from switch to HTTPS

    Intermediate & Advanced SEO
    15 6 2.1k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • roundabout
      roundabout last edited by

      Hi,

      We have a client who recently switched their site to https://

      The rule to force redirect non-secure URLs to https is in their .htaccess file:

      RewriteEngine on

      if non-SSL and one of these, redirect to SSL

      RewriteCond %{HTTPS} !on
      RewriteRule ^(.*)$ https://www.clientdomain.com/$1 [R=301,L]

      However, they also have simple redirects below this rule that redirect one page to another, such as:

      Redirect 301 /old.php https://www.clientdomain.com/new.php

      This is causing redirect chains like this:

      (A) http://www.clientdomain.com/old.php > (B) https://www.clientdomain.com/old.php > (C) https://www.clientdomain.com/new.php

      Is there any way to rewrite the rules in .htaccess to get rid of these redirect chains? So that URL A goes directly to URL C?

      Thank you!

      1 Reply Last reply Reply Quote 1
      • iugac
        iugac last edited by

        I guess you could probably do this by checking the https rule at last. So if it is old.php, the first thing you do is redirect to the new.php but already on the https. So all your static redirects will automatically go to https with one redirect while the other will always reach the last rule and go to the secure versions. Let me know if this helps.

        roundabout 2 Replies Last reply Reply Quote 2
        • roundabout
          roundabout @iugac last edited by

          Thank you! Will try and let you know 🙂

          1 Reply Last reply Reply Quote 0
          • ThompsonPaul
            ThompsonPaul last edited by

            The easy solution (and recommended best practice) is to put the specific individual redirects above the HTTPS redirect in the htaccess file. Just make certain the legacy individual redirects point to the correct HTTPS version to start with.

            It's standard procedure to have an htaccess file list the most specifically targeted rules first, gradually moving to the more general.

            Hope that helps?

            Paul

            roundabout 1 Reply Last reply Reply Quote 3
            • roundabout
              roundabout @iugac last edited by

              So the developer got back to me and said he had tried that but the redirect chain still occurred. Any other ideas?

              1 Reply Last reply Reply Quote 0
              • roundabout
                roundabout @ThompsonPaul last edited by

                So the developer got back to me and said he had tried that but the redirect chain still occurred. Any other ideas?

                1 Reply Last reply Reply Quote 0
                • willcritchlow
                  willcritchlow last edited by

                  Hi Lori. The solution the other commenters have suggested is definitely the way to do this - so it sounds like it needs more debugging. I suspect it's to do with the [L] option being needed on the specific redirect once it's moved above the general http-->https redirect. This stops other redirects below it firing, if I remember correctly.

                  If that doesn't work, do you want to share back here the specific different htaccess files the developer has tried?

                  roundabout 1 Reply Last reply Reply Quote 2
                  • roundabout
                    roundabout @willcritchlow last edited by

                    Thank you Will! Just one question, so if it's a simple redirect from one page to another, it would look like this? Or is adding [R=301,L] only for those that start with RewriteRule?

                    Redirect 301 /Bamboo https://www.fauxpanels.com/style-wood.php [R=301,L]

                    willcritchlow 1 Reply Last reply Reply Quote 0
                    • willcritchlow
                      willcritchlow @roundabout last edited by

                      Hi Lori,

                      On closer inspection, I think that only the rewriterule should have the [L] flag and that placing the specific Redirect at the top of the file should work fine without chained redirects as the other commenters suggested. I tested that here: http://htaccess.mwl.be/ and it appears to work fine using the following .htaccess - can you confirm with your developer that this is what they were trying?:

                      Redirect 301 /old.php https://www.clientdomain.com/new.php

                      RewriteEngine on

                      if non-SSL and one of these, redirect to SSL

                      RewriteCond %{HTTPS} !on
                      RewriteRule ^(.*)$ https://www.clientdomain.com/$1 [R=301,L]

                      roundabout 1 Reply Last reply Reply Quote 1
                      • roundabout
                        roundabout @willcritchlow last edited by

                        Hi Will,

                        That is correct - the developer told me that's exactly what he did. Could I send you a screenshot of the actual .htaccess file in a private message?

                        Thank you!

                        willcritchlow 1 Reply Last reply Reply Quote 0
                        • willcritchlow
                          willcritchlow @roundabout last edited by

                          Yes - of course. Happy to take a look.

                          roundabout 1 Reply Last reply Reply Quote 1
                          • roundabout
                            roundabout @willcritchlow last edited by

                            Thank you!! Just sent it

                            1 Reply Last reply Reply Quote 0
                            • lbagley
                              lbagley last edited by

                              Hi was this ever resolved as this would help many people?

                              roundabout 1 Reply Last reply Reply Quote 0
                              • roundabout
                                roundabout @lbagley last edited by

                                Hi,

                                We are still waiting for the developer to make the change. I will certainly post the answer when we know for sure!

                                Thanks

                                1 Reply Last reply Reply Quote 0
                                • creativeinnovation21
                                  creativeinnovation21 last edited by

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 1
                                  • 1 / 1
                                  • First post
                                    Last post
                                  • Ugly Redirect Chain
                                    TSEOTEAM
                                    TSEOTEAM
                                    1
                                    3
                                    41

                                  • HTTPS & Redirects
                                    Ampweb
                                    Ampweb
                                    0
                                    9
                                    114

                                  • What is the Redirect Rule for corresponding https urls to new domain with the same https urls?
                                    WSIDW
                                    WSIDW
                                    0
                                    2
                                    62

                                  • Should I redirect my HTTP to my HTTPS ?
                                    Kepass
                                    Kepass
                                    0
                                    3
                                    66

                                  • Switching from HTTP to HTTPS: 301 redirect or keep both & rel canonical?
                                    Steven_Macdonald
                                    Steven_Macdonald
                                    0
                                    9
                                    3.1k

                                  • Redirect HTTP to HTTPS
                                    alwaysriding
                                    alwaysriding
                                    0
                                    5
                                    2.0k

                                  • Moving to https: Double Redirects
                                    Matt-Williamson
                                    Matt-Williamson
                                    0
                                    4
                                    928

                                  • Redirecting, then redirecting back
                                    Highland
                                    Highland
                                    0
                                    2
                                    256

                                  Get started with Moz Pro!

                                  Unlock the power of advanced SEO tools and data-driven insights.

                                  Start my free trial
                                  Products
                                  • Moz Pro
                                  • Moz Local
                                  • Moz API
                                  • Moz Data
                                  • STAT
                                  • Product Updates
                                  Moz Solutions
                                  • SMB Solutions
                                  • Agency Solutions
                                  • Enterprise Solutions
                                  • Digital Marketers
                                  Free SEO Tools
                                  • Domain Authority Checker
                                  • Link Explorer
                                  • Keyword Explorer
                                  • Competitive Research
                                  • Brand Authority Checker
                                  • Local Citation Checker
                                  • MozBar Extension
                                  • MozCast
                                  Resources
                                  • Blog
                                  • SEO Learning Center
                                  • Help Hub
                                  • Beginner's Guide to SEO
                                  • How-to Guides
                                  • Moz Academy
                                  • API Docs
                                  About Moz
                                  • About
                                  • Team
                                  • Careers
                                  • Contact
                                  Why Moz
                                  • Case Studies
                                  • Testimonials
                                  Get Involved
                                  • Become an Affiliate
                                  • MozCon
                                  • Webinars
                                  • Practical Marketer Series
                                  • MozPod
                                  Connect with us

                                  Contact the Help team

                                  Join our newsletter
                                  Moz logo
                                  © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                                  • Accessibility
                                  • Terms of Use
                                  • Privacy