Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Moz API
      • Moz API Home
      • Compare SEO Products
      • Moz Data
    • Free SEO Tools
      • Domain Analysis
      • Keyword Explorer
      • Link Explorer
      • Competitive Research
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your all-in-one suite of SEO essentials.

      • Moz Local

        Raise your local SEO visibility with complete local SEO management.

      • STAT

        SERP tracking and analytics for enterprise SEO experts.

      • Moz API

        Power your SEO with our index of over 44 trillion links.

      • Compare SEO Products

        See which Moz SEO solution best meets your business needs.

      • Moz Data

        Power your SEO strategy & AI models with custom data solutions.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Free SEO Tools
      • Domain Analysis

        Get top competitive SEO metrics like DA, top pages and more.

      • Keyword Explorer

        Find traffic-driving keywords with our 1.25 billion+ keyword index.

      • Link Explorer

        Explore over 40 trillion links for powerful backlink data.

      • Competitive Research

        Uncover valuable insights on your organic search competitors.

      • MozBar

        See top SEO metrics for free as you browse the web.

      • More Free SEO Tools

        Explore all the free SEO tools Moz has to offer.

      What is your Brand Authority?
      Moz

      What is your Brand Authority?

      Check yours now
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

      • SEO Q&A

        Insights & discussions from an SEO community of 500,000+.

      Unlock flexible pricing & new endpoints
      Moz API

      Unlock flexible pricing & new endpoints

      Find your plan
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

      • New Releases

        Get the scoop on the latest and greatest from Moz.

      Surface actionable competitive intel
      New Feature

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Moz API
      • Moz API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

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

    1. Home
    2. SEO Tactics
    3. Technical SEO
    4. Redirection chain and Javascript Redirect

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    Redirection chain and Javascript Redirect

    Technical SEO
    10
    19
    2283
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question management privileges can see it.
    • LouisPortier
      LouisPortier Subscriber last edited by

      Hi,

      A redirection chain is usually defined as a page redirecting to another page which itself is another redirection.

      URL1 ---(301/302)---> URL2 ---(301/302)---> URL3

      But what about Javascript redirect? They seem to be a different beast:

      URL1 ---(301/302)---> URL2 ---(200 then Javascript redirect)---> URL3

      From what I know if the javascript redirect is instant Google counts it as a 301 permanent redirection, but I'm still not sure about if this counts as a redirection chain.

      Most of the tools (such as moz) only see the first redirection.

      So is that scenario a redirection chain or no?

      evanmirk vimu786 2 Replies Last reply Reply Quote 0
      • freepointofsales
        freepointofsales last edited by

        It's a delicate balance between efficient routing and ensuring seamless transitions, where every decision shapes the user's path and perception. myvirtualworkplace

        1 Reply Last reply Reply Quote 0
        • vimu786
          vimu786 @LouisPortier last edited by

          @LouisPortier said in Redirection chain and Javascript Redirect:

          Hi,

          A redirection chain is usually defined as a page redirecting to another page which itself is another redirection.

          URL1 ---(301/302)---> URL2 ---(301/302)---> URL3

          But what about Javascript redirect? They seem to be a different beast:

          URL1 ---(301/302)---> URL2 ---(200 then Javascript redirect)---> URL3

          From what I know if the javascript redirect is instant Google counts it as a 301 permanent redirection, but I'm still not sure about if this counts as a redirection chain.

          Most of the tools (such as moz) only see the first redirection.

          So is that scenario a redirection chain or no?

          A JavaScript redirect, on the other hand, is a redirect that occurs using JavaScript code embedded in a webpage. Instead of relying on server-side redirects, JavaScript redirects are triggered when the page loads or when certain conditions are met, and they instruct the browser to navigate to a different URL. They can be used for various purposes, such as redirecting users after a certain amount of time, after a form submission, or based on user interactions.

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

            Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

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

              Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

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

                Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

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

                  Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

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

                    Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

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

                      Understanding the intricacies of redirection chains and JavaScript redirects is crucial for optimizing website performance and user experience. Proper implementation ensures smooth navigation and avoids unnecessary delays. Visit more

                      1 Reply Last reply Reply Quote 0
                      • James.Mathew
                        James.Mathew last edited by

                        I appreciate your detailed explanation. To enhance accuracy in tracing redirects, ensure a cohesive sequence. Consider using a unified approach for hash numbers, perhaps generating a unique identifier for each transition. Additionally, refine the code logic to account for different redirection techniques, ensuring a seamless and connected mapping of the entire journey from A to D. If possible, share snippets of your code for more targeted guidance. shopify website design servicee austin

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

                          Thank you for the valuable feedback. While the current code successfully executes, it lacks accuracy in tracing the redirect sequence. The issue stems from the disjointed nature of the captured redirects, as seen in the isolated transitions from A to B, B to C, and C to D, where randomly generated hash numbers (channel_1 and channel_2) are utilized. This disrupts the continuity of the redirect chain, resulting in an inaccurate representation of the actual progression from A through D.

                          The objective is to effectively track the entire journey, encompassing transitions from A to B to C to D, across various redirection techniques such as meta-refresh, JavaScript, and HTTP redirects. I would greatly appreciate your guidance on refining the code to maintain the integrity of the redirect sequence, ensuring a connected and sequential mapping of the redirection process. Liteblue

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

                            Thank you for the valuable feedback. While the current code successfully executes, it lacks accuracy in tracing the redirect sequence. The issue stems from the disjointed nature of the captured redirects, as seen in the isolated transitions from A to B, B to C, and C to D, where randomly generated hash numbers (channel_1 and channel_2) are utilized. This disrupts the continuity of the redirect chain, resulting in an inaccurate representation of the actual progression from A through D.

                            The objective is to effectively track the entire journey, encompassing transitions from A to B to C to D, across various redirection techniques such as meta-refresh, JavaScript, and HTTP redirects. I would greatly appreciate your guidance on refining the code to maintain the integrity of the redirect sequence, ensuring a connected and sequential mapping of the redirection process. Liteblue

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

                              In the scenario you described, where there is a sequence of redirects involving both HTTP redirects (301/302) and a JavaScript redirect, it can be considered a redirection chain. The key point is that each step in the sequence contributes to the final destination of the URL.

                              In your example:

                              1. URL1 redirects to URL2 using an HTTP 301/302 status code.
                              2. URL2, after an HTTP 200 response, triggers a JavaScript redirect to URL3.

                              From Google's perspective, if the JavaScript redirect is instantaneous and does not introduce a delay, it might treat it similarly to a traditional 301 permanent redirect. However, it's important to note that search engines may interpret JavaScript redirects differently, and their behavior may evolve over time.

                              Tools like Moz may sometimes focus on the initial HTTP redirect and not delve into subsequent steps, potentially overlooking the complete redirection chain. Therefore, discrepancies in what different tools report could occur.

                              For a more comprehensive understanding, you might consider using tools or methods that specifically analyze JavaScript-based redirects or inspect the network requests in a browser's developer tools to see the entire redirection sequence. This way, you can get a clearer picture of how search engines and various tools interpret the entire redirection chain, including both HTTP and JavaScript redirects.

                              1 Reply Last reply Reply Quote 0
                              • arron-williams
                                arron-williams last edited by

                                Thank you for the insightful feedback. While the current code executes successfully, it falls short in accurately tracing the redirect sequence. The issue lies in the disjoint nature of the captured redirects, exemplified by the isolated transitions A->B, B->C, and C->D, where the hash numbers (channel_1 and channel_2) are generated randomly. This disrupts the continuity of the redirect chain, failing to reflect the actual progression from A through D. The goal is to effectively track the entire journey, A->B->C->D, across different redirection techniques such as meta-refresh, JavaScript, and HTTP redirects. Could you provide guidance on how to refine the code to maintain the integrity of the redirect sequence, ensuring a connected and sequential mapping of the redirection process?

                                1 Reply Last reply Reply Quote 0
                                • arron-williams
                                  arron-williams last edited by

                                  Thank you for the insightful feedback. While the current code executes successfully, it falls short in accurately tracing the redirect sequence. The issue lies in the disjoint nature of the captured redirects, exemplified by the isolated transitions A->B, B->C, and C->D, where the hash numbers (channel_1 and channel_2) are generated randomly. This disrupts the continuity of the redirect chain, failing to reflect the actual progression from A through D. The goal is to effectively track the entire journey, A->B->C->D, across different redirection techniques such as meta-refresh, JavaScript, and HTTP redirects. Could you provide guidance on how to refine the code to maintain the integrity of the redirect sequence, ensuring a connected and sequential mapping of the redirection process? Liteblue

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

                                    Thank you for your feedback. While the code is currently functional, it doesn't yield the expected outcome. The recorded redirect chain appears disjointed, capturing transitions like A->B (channel_1 -> channel_2), B->C (channel_1 -> channel_2), and C->D (channel_1 -> channel_2). The issue lies in the randomly generated hash numbers (channel_1 and channel_2), preventing the proper linkage of the redirect chain. The goal is to accurately capture sequential events such as A->B->C->D, considering various redirection methods like meta-refresh, JavaScript, and HTTP. How can I modify the code to implement this strategy and ensure the redirection chain is connected as intended?

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

                                      Thank you for your feedback. Although the code is functional, it does not produce the expected result. Currently, the recorded redirect chain is disjointed, capturing transitions like A->B (channel_1 -> channel_2), B->C (channel_1 -> channel_2), and C->D (channel_1 -> channel_2). In this case, the hash numbers (channel_1 and channel_2) are randomly generated, preventing the proper linking of the redirect chain. The objective is to accurately capture the sequential events of A->B->C->D, considering various redirection methods such as meta-refresh, JavaScript, and HTTP. How can I modify the code to achieve this strategy and ensure the redirection chain is connected as intended? Liteblue

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

                                        thx, the code works, but not as expected: A->B->C->D (channel_1 -> channel_2 -> channel_3 -> channel_4).

                                        In my case it will record a redirect chain of A->B->C->D like:

                                        A->B (channel_1 -> channel_2), than B->C (channel_1 -> channel_2), C->D (channel_1 -> channel_2); where channel_1 & channel_2 are random hash numbers.

                                        So I can not link the chain together. that would be the strategy to capture the chain of events (while the pages redirect using, meta-refresh, javascript, http...)? Liteblue USPS

                                        1 Reply Last reply Reply Quote 0
                                        • evanmirk
                                          evanmirk @LouisPortier last edited by

                                          window.location.replace('http://example.com');
                                          

                                          It's better than using window.location.href = 'http://example.com';

                                          Using replace() is better because it does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.

                                          If you want to simulate someone clicking on a link, use window.location.href

                                          If you want to simulate an HTTP redirect, use window.location.replace

                                          You can use assign() and replace methods also to javascript redirect to other pages like the following:

                                          location.assign("http://example.com");
                                          

                                          The difference between replace() method and assign() method(), is that replace() removes the URL of the current document from the document history, means it is not possible to use the "back" button to navigate back to the original document. So Use the assign() method if you want to load a new document, andwant to give the option to navigate back to the original document.

                                          1 Reply Last reply Reply Quote 1
                                          • 1 / 1
                                          • First post
                                            Last post

                                          Got a burning SEO question?

                                          Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                                          Start my free trial


                                          Browse Questions

                                          Explore more categories

                                          • Moz Tools

                                            Chat with the community about the Moz tools.

                                          • SEO Tactics

                                            Discuss the SEO process with fellow marketers

                                          • Community

                                            Discuss industry events, jobs, and news!

                                          • Digital Marketing

                                            Chat about tactics outside of SEO

                                          • Research & Trends

                                            Dive into research and trends in the search industry.

                                          • Support

                                            Connect on product support and feature requests.

                                          • See all categories

                                          Related Questions

                                          • thinkLukeSEO

                                            Backlinks that go to a redirected URL

                                            Hey guys, just wondering, my client has 3 websites, 2 of 3 will be closed down and the domains will be permanently redirected to the 1 primary domain - however they have some high quality backlinks pointing the domains that will be redirected. How does this effective SEO? Domain One (primary - getting redesign and rebuilt) - not many backlinks
                                            Domain Two (will redirect to Domain One) - has quality backlinks
                                            Domain Three (will redirect to Domain One) - has quality backlinks When the new website is launched on Domain One I will contact the backlink providers and request they update their URL - i assume that would be the best.

                                            Technical SEO | | thinkLukeSEO
                                            0
                                          • DanielKiely6

                                            Hreflang tags with link to redirect loop

                                            Hi guys, I'm having a bit of an issue on a client site that I'm hoping someone can help me with. Basically, the client has two domains, one serving users in the Republic of Ireland (http://www.americanholidays.com), showing Euro prices, and the other serving users in Northern Ireland (http://www.americanholidays.com/gb_en/) showing £ prices. The issue I'm having is that the URL for the Northern Ireland page has a 302 on it and goes through another 2/3 301 redirects until it resolves as http://www.americanholidays.com, however it does then show the £ prices. You can see the redirect chain here: http://tools.seobook.com/server-header-checker/?page=single&url=http%3A%2F%2Fwww.americanholidays.com%2Fgb_en%2F&useragent=1&typeProtocol=11 The homepage is using the Hreflang tag, and pointing search engines to serve the http://www.americanholidays.com/gb_en/ page to users using EN-GB as their language. The page is also using a self-referencing canonical, which I believe may negate the whole Hreflang tag anyway? My main question is - is the fact that the Hreflang for the gb_en page is pointing to a chain of redirects negatively affecting it? (I understand too many redirects are never good). Also, is the canonical negating the Hreflang? Any help/info would be great as I just can't get my head around it! Thanks guys Daniel

                                            Technical SEO | | DanielKiely6
                                            0
                                          • Silviu

                                            301 redirect relative or absolute path?

                                            Hello everyone, Recently we've changed the URL structure on our website, and of course we had to 301 redirect the old urls to the coresponding new ones. The way the technical guys did this is: "http://www.domain.com/old-url.html" 301 redirect to "/new-url.html"
                                            meaning as a relative redirect path, not an absolute one like this:
                                            "http://www.domain.com/old-url.html" 301 redirect to "http://www.domain.com/new-url.html" This happened for few thousands urls, and the fact is the organic traffic dropped for those pages after this change. (no other changes were made on these pages and the new urls are as seo friendly as possible, A grade on On-Page Grader). The question is: does the relative redirect negatively affects seo, or it counts the same as an absolute path redirect? Thanks,
                                            S.

                                            Technical SEO | | Silviu
                                            0
                                          • SDSLaw

                                            Questions about the Sandbox and 301 Redirects

                                            Does the sandbox still exist?  What if you have a brand new URL and do a 301 redirect from another website because the name of the service business changed? Thanks for any insight and help.

                                            Technical SEO | | SDSLaw
                                            0
                                          • RyanOD

                                            Removing Redirected URLs from XML Sitemap

                                            If I'm updating a URL and 301 redirecting the old URL to the new URL, Google recommends I remove the old URL from our XML sitemap and add the new URL. That makes sense. However, can anyone speak to how Google transfers the ranking value (link value) from the old URL to the new URL? My suspicion is this happens outside the sitemap. If Google already has the old URL indexed, the next time it crawls that URL, Googlebot discovers the 301 redirect and that starts the process of URL value transfer. I guess my question revolves around whether removing the old URL (or the timing of the removal) from the sitemap can impact Googlebot's transfer of the old URL value to the new URL.

                                            Technical SEO | | RyanOD
                                            0
                                          • darkanweb

                                            Htaccess redirect with question mark

                                            Hi I have a problem setting up my htaccess for a specific page that has a question mark in the link, and one that has a space in the link and also a question mark. So I would like 2 redirects in my htaccess like that: www.olddomain.com/page.php?page=pagename1 to www.newdomain.com/newpage1.html www.olddomain.com/page.php?page=page name2 to www.newdomain.com/newpage2.html I have tried with something like this but doesn't work: RewriteEngine on RewriteRule ^page.php?page=pagename1 "http://www.newdomain.com/newpage1.html" [R=301,L] RewriteRule ^page.php?page=page name2 "http://www.newdomain.com/newpage2.html" [R=301,L] Could someone tell me what exactly I have to change? Thanks

                                            Technical SEO | | darkanweb
                                            0
                                          • CarsProduction

                                            Do search engines treat 307 redirects differently from 302 redirects?

                                            We will need to send our users to an alternate version of our homepage for a few hours for a certain event. The SEO task at hand is to minimize the chance of the special homepage getting crawled and cached in the search engines in place of our normal homepage. (This has happened in the past so the concern is not imaginary.) Among other options, 302 and 307 redirects are being discussed. IE, redirecting www.domain.com to www.domain.com/specialpage. Having used 302s and 301s in the past, I am well aware of how search engines treat them. A 302 effectively says "Hey, Google! Please get rid of the old content on www.domain.com and replace it with the content on /specialpage!" Which is exactly what we don't want. My question is: do the search engines handle 307s any differently? I am hearing that the 307 does NOT result in the content of the second page being cached with the first URL. But I don't see that in the definition below (from w3.org). Then again, why differentiate it from the 302? 307 Temporary Redirect The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI. If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

                                            Technical SEO | | CarsProduction
                                            0
                                          • brightonseorob

                                            Someone is redirecting their url to mine

                                            Hello, I have just discovered that a company in Poland www.realpilot.pl is directing their domain to ours www.transair.co.uk. We have not authorised this, neither do we want this. I have contacted the company and the webmaster to get it removed. If you search for the domain name www.realpilot.pl we (www.transair.co.uk) come up top. My biggest worry is that we will get penalised by Google for this re-direct as it appears to be done using some kind of frame. Does anyone know anything about this kind of thing? Many Thanks Rob Martin

                                            Technical SEO | | brightonseorob
                                            0

                                          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
                                          Free SEO Tools
                                          • Domain Authority Checker
                                          • Link Explorer
                                          • Keyword Explorer
                                          • Competitive Research
                                          • Brand Authority 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 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                                          • Accessibility
                                          • Terms of Use
                                          • Privacy

                                          Looks like your connection to Moz was lost, please wait while we try to reconnect.