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. Web Design
    4. Display a message after 301 redirect.

    Display a message after 301 redirect.

    Web Design
    5 2 2.3k
    • 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.
    • WilliamBay
      WilliamBay last edited by

      I know this one is a little more technical than pure SEO, but it somewhat ties in.

      I'm redirecting 2 sites to one. The companies have combined, and I've imported all their content that has been created, and the url mapping is set up correctly.

      So it currently is set up like this:

      A.com --> C.com
      A.com/blogpost-1 --> C.com/blogpost-1

      B.com --> C.com B.com/blogpost-20 --> C.com/blogpost-20

      What i would like is some method a redirect when landing at C.com or C.com/blogpost-XX.

      And in turn display a message in a DIV so I can style it.

      And yes, I have nothing better to do on a Friday night 🙂

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

        Hi William,

        Shouldn't be too hard. In that 301 redirect, add a GET query.

        i.e. A question mark after the URL in the redirect that says something like:

        http://www.new-url.com?redirect=true

        What this will mean is that on your NEW site, you can add a query like (if using PHP):

        if(isset($_GET['redirect')){

        if($_GET['redirect'] == 'true'){

        ?>

        You were redirected!

        }

        }

        Decoding this, it basically checks for a question mark in the url, and if it finds one, it adds the div with the class "redirected" and says something!

        Let me know if that didn't make sense!

        WilliamBay 1 Reply Last reply Reply Quote 1
        • JoshPugh
          JoshPugh last edited by

          P.S. Ensure that you have rel="canonical" on the new URL because otherwise you won't be getting proper SEO for the pages with the ?redirect=true

          🙂

          1 Reply Last reply Reply Quote 0
          • WilliamBay
            WilliamBay @JoshPugh last edited by

            Thanks for this! It wasn't working for me initially, and asked around. looks like you missed a "]" in the first line. So it should be:

            if(isset($_GET['redirect'])){

            I was able to get it to work at the root domain. A.com --> C.com

            After getting this all sorted out though, I realize that I really wanted a pop up screen that could be closed, and that it would require me to spend even more time on it, and trying to add javascript as well. I decided to just scrap the idea.

            Another problem I had was that the ?redirect=true at the end of the URL, messed up the direct linking to subpages and posts as well. So instead of :

            C.com/blogpost-20 I would get C.com?redirect=true/blogpost-20.

            Since there is no such page, it just returned the contents from the home page.

            I appreciate your help though. It just seems like more effort that I want to put in, and probably more than the client wants to pay for.

            JoshPugh 1 Reply Last reply Reply Quote 0
            • JoshPugh
              JoshPugh @WilliamBay last edited by

              Ah sorry about missing the bracket.

              Yeah the ? query has to come at the very end, otherwise it interrupts the flow of the URL... So it should be C.com/blogpost-20?redirect=true

              There is lots you can do, but I understand that it may be a bit more work than you planned 🙂

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              • Should I do multiple 301 redirects?
                nhhernandez
                nhhernandez
                0
                2
                987

              • 301 Redirect all pictures when moving to a new site?
                DirkC
                DirkC
                0
                4
                4.1k

              • 301 Redirect Issue for URL with # and !
                BlueprintMarketing
                BlueprintMarketing
                0
                4
                2.5k

              • Advanced 301 Redirects
                Travis_Bailey
                Travis_Bailey
                0
                3
                254

              • HTTPS redirecting to subdomain; do I need to 301 to HTTP first?
                alimo
                alimo
                0
                5
                346

              • 301 Redirect from Old Domain to New Domain
                Chris.Menke
                Chris.Menke
                0
                2
                1.3k

              • What happens if I 301 Redirect my homepage to a different page on site
                SheffieldMarketing
                SheffieldMarketing
                0
                10
                364

              • Show root domain (that is 301 redirected) in SERP?
                MoosaHemani
                MoosaHemani
                0
                7
                1.1k

              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