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. Redirect everything from a certain url

    Redirect everything from a certain url

    Technical SEO Issues
    10 4 516
    • 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.
    • EclipseLegal
      EclipseLegal last edited by

      I have a new domain (www.newdomain.com) and and an old domain (www.olddomain.com).

      Currently both domains are pointing (via dns nameserves) at the new site. I want to 301 everything that comes from the www.oldsite.com to www.newsite.com.

      I've used this htaccess code

      RewriteEngine On

      RewriteCond %{HTTP_HOST} !^www.newsite.com$
      RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]

      Which works fine and redirects if someone visits www.olddomain.com but I want it to cover everything from the old domain such as www.olddomain.com/archives/article1/ etc. So if any subpages etc are visited from the old domain its redirected to the new domain.

      Could someone point me in the right direction?

      Thanks

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

        Hi James,

        I made some research, and there is several solutions, some depends on your Apache version. Try the rule above to see if it solve your problem:

        RedirectMatch permanent /.* http://www.newdomain.com/

        If not, you should take a look at http://stackoverflow.com/ The website has a lot of discussion on this theme.

        EclipseLegal 1 Reply Last reply Reply Quote 1
        • EclipseLegal
          EclipseLegal @Naghirniac last edited by

          Ok, how would I fit that into the above htacess code?

          Thanks

          Naghirniac EclipseLegal 4 Replies Last reply Reply Quote 0
          • Naghirniac
            Naghirniac @EclipseLegal last edited by

            You can use like this:

            RewriteEngine On

            RewriteCond %{HTTP_HOST} !^www.newsite.com$
            RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]

            RedirectMatch permanent /.* http://www.newdomain.com/

            1 Reply Last reply Reply Quote 0
            • EclipseLegal
              EclipseLegal @EclipseLegal last edited by

              Thanks tired that but I just get a error saying

              This webpage has a redirect loop

              1 Reply Last reply Reply Quote 0
              • Naghirniac
                Naghirniac @EclipseLegal last edited by

                Leave only the 
                RedirectMatch permanent /.* http://www.newdomain.com/

                take out the other part

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

                  Hi James, a question, do you want all the old pages simply to redirect to the new "home page" or do you have new versions of the old pages on your new domain?  While I lack the detailed programming knowledge of Naghirniac; it seems to me that you should have a think about whether you want visitors who land on the old site's blue widget's page (assuming there is any traffic or link juice flowing in) to be redirected to a new version of blue widgets page on the new domain; rather than just a blanket transfer to the home page?  If that's the case and you aren't talking thousands of pages 😉 then maybe redirects from each page would be worth thinking about?

                  Good luck anyhow!

                  EclipseLegal 1 Reply Last reply Reply Quote 0
                  • EclipseLegal
                    EclipseLegal @SkiBum last edited by

                    Thanks, you are indeed right however in this case I need to redirect the old domain and all of its pages to the home page of the new.

                    I just need to know how to say if anything from www.olddomain.com INCLUDING sub pages and folders hits my site then redirect it to www.newsite.com. Both domain names are pointing at the same hosting.

                    Can anyone help?

                    evolvingSEO 1 Reply Last reply Reply Quote 0
                    • EclipseLegal
                      EclipseLegal @EclipseLegal last edited by

                      So which part shouldI remove - the RewriteCond or/and RewriteRule?

                      Thanks

                      1 Reply Last reply Reply Quote 0
                      • evolvingSEO
                        evolvingSEO @EclipseLegal last edited by

                        I'm not sure why you wouldn't want to send individual pages to the corresponding new ones on the new site.

                        But a really crude way to just point an entire old domain at a new one is to use "domain forwarding" - you'll set this up with whoever you manage the domain name with.

                        Explanation from GoDaddy

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        • 301 Redirects, Sitemaps and Indexing - How to hide redirected urls from search engines?
                          LoganRay
                          LoganRay
                          0
                          4
                          3.0k

                        • Should I change or redirect this URL?
                          KempRugeLawGroup
                          KempRugeLawGroup
                          0
                          6
                          115

                        • URL redirect question
                          AlanMosley
                          AlanMosley
                          0
                          8
                          165

                        • OSE says URL redirects to URL with trailing slash but it doesn't.
                          rock22
                          rock22
                          0
                          5
                          211

                        • I have altered a url as it was too long. Do I need to do a 301 redirect for the old url?
                          TomRayner
                          TomRayner
                          0
                          4
                          181

                        • Can I redirect a URL that has a # in it? How?
                          ASOS
                          ASOS
                          0
                          7
                          422

                        • Redirect or not to redirect
                          AlanMosley
                          AlanMosley
                          0
                          7
                          458

                        • Is a 302 redirect the correct redirect from a root URL to a detail page?
                          KeriMorgret
                          KeriMorgret
                          0
                          7
                          1.8k

                        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