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 redirects

    Htaccess redirects

    Technical SEO Issues
    3 2 220
    • 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.
    • ThomasHarvey
      ThomasHarvey last edited by

      Annoyingly it's time to play with this beast again.

      I've been given the task of doing the following.

      Keeping the homepage live

      Redirecting categories to the specific categories on the new site

      Catch all redirects

      Now i've managed to setup the specific categories and the catch all redirects, however I am unsure how to keep the homepage live (which is like this:www.domain.com/ so I can't just exclude that?)

      Would appreciate any help.

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

        Got around this by adding catch alls for a-z/0-9.

        RewriteRule ^a(.*) http://www.domain.com? [R=301,NE,NC,L]

        This meant that the homepage wasn't being touched. However I did lose all of the category specific redirects. I'm sure there was a way around this however I don't know htaccess to do this well enough. Would be interesting if anyone would know how to do all three?

        Tom-Anthony 1 Reply Last reply Reply Quote 1
        • Tom-Anthony
          Tom-Anthony @ThomasHarvey last edited by

          If I have understood it correctly, you want:

          • To redirect certain category pages to new category pages on a new domain.
          • Redirect all other pages to the homepage on a new domain
          • Not to redirect the homepage and for that to stay on the current domain.

          If so I think this should probably do what you want:

          RewriteRule ^$ - [L]
          RewriteRule categoryA/ http://www.newdomain.com/newcategoryA/ [R=301,L]
          RewriteRule (.+) http://www.newdomain.com/ [R=301,L]

          The first rule says "if this is the homepage stop evaluating rules". The second maps a category page over to the new version and stops evaluating rules; you'll need to duplicate this one for all the specific categories. The last rule is your catch-all rule for redirecting everything else to the homepage of the new domain.

          If you want to easily test/check then I highly recommend this .htaccess checker tool.

          Good luck! 🙂

          1 Reply Last reply Reply Quote 2
          • 1 / 1
          • First post
            Last post
          • Where to put 301 redirects in my Wordpress htaccess file?
            Benspain
            Benspain
            0
            3
            34

          • .htaccess Redirect 301 issues
            Cyberace
            Cyberace
            0
            5
            140

          • Help creating a 301 redirect in my htaccess file
            Felip3
            Felip3
            0
            4
            108

          • 301 redirect .htaccess
            Christy-Correll
            Christy-Correll
            0
            5
            234

          • Htaccess redirect with question mark
            darkanweb
            darkanweb
            0
            3
            2.2k

          • HTACCESS redirect vs. forwarding
            Highland
            Highland
            0
            2
            304

          • Redirects on Window Servers - .htaccess equivalent for IIS
            Getz.pro
            Getz.pro
            0
            2
            4.1k

          • 301 redirect .htaccess problem
            sferrino
            sferrino
            0
            4
            709

          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