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. .htaccess code

    .htaccess code

    Technical SEO Issues
    8 3 68
    • 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.
    • abisti2
      abisti2 last edited by

      I've got a .htaccess file set up on a site to redirect specific old pages to specific new pages on a different site:

      eg

      Redirect 301 /oldpage.html https://www.newsite.co.uk/newpage.html

      Redirect 301 /oldpage2.html https://www.newsite.co.uk/folder/

      I have two questions:

      1. Is that all the file needs? Or does it need any "rewrite engine on" type code?

      2. I would also like to include code to "mop up" any other URLs and redirect them to the root, so that

      /anyotherpage.html redirects to newsite.co.uk

      Is there a way to do this?

      1 Reply Last reply Reply Quote 0
      • Andy-Halliday
        Andy-Halliday last edited by

        Your current redirects are fine and the best way is if its live to test it. Even thought I knew I had done it right recently when i went to https, I still do several random checks. They all came back as working - but no harm in testing.

        Your point 2 is doable and as I am not on my laptop I don't have the code to hand. I will update in a few hours when back in the office for you, but your point 1 is correct.

        abisti2 1 Reply Last reply Reply Quote 1
        • abisti2
          abisti2 @Andy-Halliday last edited by

          Thanks Andy, much appreciated. I'll look forward to the code 🙂

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

            2.) Are you talking about a catch-all? You can use 404 and redirect them to whatever. Try to redirect as much as possible though. Good luck!

            ErrorDocument 404 /index.html

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

              Hi Kevin

              Many thanks for this. Is a 404 as effective in passing on link juice as a 301?

              KevinBudzynski 1 Reply Last reply Reply Quote 0
              • KevinBudzynski
                KevinBudzynski @abisti2 last edited by

                Not really, since the resource doesn't exist anymore. If the resource exists (or something close to it) it would be a 301 and link juice will be passed (although not 100% of it).

                If you have a relevant page, you should always 301 them. I would go through analytics and makes sure any "valuable" page has a relevant landing page. If no relevant landing page exists, you should 404 the result will eventually fall off.

                I would also advise on creating a custom 404 page that explains what they are looking for and doesn't exist and show alternative pages/search bar. Users may get confused if they were looking for something specific and land at your home page.

                abisti2 1 Reply Last reply Reply Quote 0
                • abisti2
                  abisti2 @KevinBudzynski last edited by

                  Thanks Kevin - I'm not sure I completely understand though.

                  What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site.

                  Are you saying there's not point in using a 301 if the page doesn't exist? I don't really understand why you'd use a 301 if the page still existed...?

                  KevinBudzynski 1 Reply Last reply Reply Quote 0
                  • KevinBudzynski
                    KevinBudzynski @abisti2 last edited by

                    What I'm looking to do is pass the link juice on from about 5,000 backlinks still pointing at our old site (which exists in domain form only a present) to the new site.  Are these links pointed to the home page? Or are these pointed at relevant landing pages? If to the home page (and page is same on new site) nothing is needed. If  these links are pointed to a landing page, you will need to route them to a related page on the new site and 301.

                    Are you saying there's not point in using a 301 if the page doesn't exist? Yes, no point unless there is a new landing page that is some-how related.

                    I don't really understand why you'd use a 301 if the page still existed...? If the page is on the new site and is the same url, no 301 is needed.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    • Htaccess noob
                      Keszi
                      Keszi
                      0
                      4
                      96

                    • Redirect 302 status code to 301 status code
                      rijwielcashencarry040
                      rijwielcashencarry040
                      0
                      5
                      145

                    • Https and 404 code that goes into htaccess
                      0
                      1
                      135

                    • .htaccess redirects
                      ThompsonPaul
                      ThompsonPaul
                      0
                      15
                      285

                    • Htaccess Rewrites
                      Klement69
                      Klement69
                      0
                      4
                      316

                    • Htaccess query
                      ShaMenz
                      ShaMenz
                      0
                      6
                      469

                    • Schema coding
                      DragonSearch
                      DragonSearch
                      0
                      3
                      647

                    • Non-www to www code not working in htaccess
                      JaspalX
                      JaspalX
                      0
                      4
                      667

                    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