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. Technical SEO Issues
    4. 301 domain name to another site

    301 domain name to another site

    Technical SEO Issues
    9 2 112
    • 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.
    • bhsiao
      bhsiao last edited by

      I had 2 websites. I decided not to maintain one of them and set it to 301 to my main website. However, i see people getting 404 errors when they land on my main website but with a page name from the old site. How can I set things so that anyone who tries to go to the old site goes to my homepage of my main site?

      http://siteA.com

      http://oldsiteB.com/oldpagename sends them to http://siteA.com//oldpagename = 404  - I want them to go directly to homepage on siteA.

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

        Hi,

        You have 2 methods that i would use:

        Method #1: using .htaccess

        Option A: redirect one specific URL to a new specific URL:
        _Redirect 301 /old/old.html http://NEWSITE/new.html_

        Note: 'old/old.html' has to be without the domain name: so just the directory + page.

        Option B: redirect an entire directory to a new specific URL:
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^OLDSITE.com [NC,OR]
        RewriteCond %{HTTP_HOST} ^www.OLDSITE.com [NC]
        RewriteRule ^(.*)$ http://NEWSITE/$1 [L,R=301,NC]

        Note: the second line of that example has to be without 'www'.

        Method #2: using PHP

        If you have one header-file, you can place this code in the top of that php-file:
        header( "Status: 301 Moved Permanently" ); header( "Location: http://NEWSITE" ); exit(0); ?>

        Would that provide an answer for you?

        Yours,
        Bas

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

          Can I use this option and somehow direct all traffic from old site to my new home page? I tried this and if someone was trying to find a specific page on the old site they get a 404 on the new.

          RewriteEngine on
          RewriteCond %{HTTP_HOST} ^OLDSITE.com [NC,OR]
          RewriteCond %{HTTP_HOST} ^www.OLDSITE.com [NC]
          RewriteRule ^(.*)$ http://NEWSITE/$1 [L,R=301,NC]

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

            Ok so i had to test this one because i wasn't sure but you would have to remove "$1" from the last line.

            That piece actually will add the file path of the original domain and add it to the domain you are redirecting the visitor to.

            So this "www.myoldsite.com/my-page/"
            Will become "www.mynewsite.com/my-page/"

            Since you want it this way:
            Old URL: "www.myoldsite.com/my-page/"
            New URL: "www.mynewsite.com/"

            Removing the "$1" should do the trick.

            Is this an answer to your question?

            Bas

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

              Yes, that helps, thank you!

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

                Actually, I tried that, and the result is still

                Old URL: "www.myoldsite.com/my-page/"
                New URL: "www.mynewsite.com/404.html

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

                  Ok, just to be sure: you have placed this .htaccess on the old site. Right?

                  If that is the case and you've pasted the exact code i mentioned, then something else might be causing the issue.

                  Also: be sure to try this with a browser that hasn't visited the site in a while. It happens to me sometimes that the browser will simply remember the redirect and not follow the .htaccess.

                  Hope any of this helps!

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

                    No, I put it on the .htaccess on the new site. I had 301'd the whole old site in my domain name manager. Maybe I should not do that so I can put an .htaccess file right on the old domain?

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

                      Try to put that .htaccess on the old site. It will rewrite the asked URL before it can be processed by the server. It will rewrite the request to contain the new domain.

                      On the new domain, you already have the code to process these requests.

                      Try that and report back. It probably works after that.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      • 301 Old Domain Name with relevant domain name
                        0
                        1
                        32

                      • Will doing a 301 redirect for one domain to another give the latter domain the formers links?
                        mickburkesnr
                        mickburkesnr
                        0
                        5
                        128

                      • Questions on switching domain name of my site
                        deathbyseo
                        deathbyseo
                        0
                        5
                        99

                      • Will Links to one Sub-Domain on a Site hurt a different Sub-Domain on the same site by affecting the Quality of the Root Domain?
                        ifbyphone
                        ifbyphone
                        0
                        5
                        153

                      • When to 301 a No1 ranking site to the new domain?
                        CaseyKluver
                        CaseyKluver
                        0
                        5
                        332

                      • How to 301 multiple domain names to a single domain
                        KeriMorgret
                        KeriMorgret
                        0
                        9
                        1.5k

                      • Delete old site but redirect domain to a new domain and site
                        AaronSchinke
                        AaronSchinke
                        0
                        4
                        828

                      • 301 redirects and old domain names
                        RiceMedia
                        RiceMedia
                        0
                        4
                        802

                      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