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. Intermediate & Advanced SEO
    4. Htaccess Issue: URL not resolving properly

    Htaccess Issue: URL not resolving properly

    Intermediate & Advanced SEO
    3 3 128
    • 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.
    • inhouseseo
      inhouseseo last edited by

      I am merging a niche site, tshirts.com to another site mainsite.com.

      I am using an htaccess file on a linux server, and the homepage of the niche site is being directed to the corresponding category page on the main site (i.e nichesite.com to mainsite.com/niche.html). Everything else is also a page to page redirect.

      I have something like this in the htaccess file:

      Redirect 301 http://tshirts.com/ http://www.mainsite.com/tshirts.html
      Redirect 301 http://tshirts.com/blue.html  http://www.lampclick.com/blue-t-shirts.html
      Redirect 301 http://tshirts.com/white.html http://www.mainsite.com/white-t-shirts.html
      Redirect 301 http://tshirts.com/black-tshirts.html http://www.mainsite.com/bk-t-shirts.html

      When I check 301 for lets say http://tshirts.com/blue.html, I get:

      http://tshirts.com/blue.html -** 301 Moved Permanently**

      http://www.mainsite.com/tshirts.htmlblue.html -** 302 Found**

      http:www.mainsite.com/

      How do I fix this? Why is everything being appended to minsite/tshirts.html?

      I appreciate your help.

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

        Hi there,

        Redirects should always be written in a relative to absolute path.

        So the .htaccess file for http://tshirts.com/ should contain something like:

        Redirect 301 / http://www.mainsite.com/tshirts.html
        Redirect 301 /blue.html  http://www.lampclick.com/blue-t-shirts.html
        Redirect 301 /white.html http://www.mainsite.com/white-t-shirts.html
        Redirect 301 /black-tshirts.html http://www.mainsite.com/bk-t-shirts.html

        I think that should solve the issue.

        Keszi

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

          The problem is the order here. Remember that redirects fire from top down. In this case, you're telling it to redirect the main page, then redirect the secondary page, so what you get is / redirects to http://www.mainsite.com/tshirts.html and then it tries to redirect /blue.html but it's already done the previous redirect, so it tries to append blue.html to this and you end up with what you did, http://www.mainsite.com/tshirts.htmlblue.html

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          • Product search URLs with parameters and pagination issues - how should I deal with them?
            LoganRay
            LoganRay
            0
            10
            532

          • Redirect Issue in .htaccess
            ThompsonPaul
            ThompsonPaul
            0
            2
            368

          • Issue with site not being properly found in Google
            Christy-Correll
            Christy-Correll
            1
            5
            212

          • Client wants to remove mobile URLs from their sitemap to avoid indexing issues. However this will require SEVERAL billing hours. Is having both mobile/desktop URLs in a sitemap really that detrimental to search indexing?
            RosemaryB
            RosemaryB
            0
            7
            89

          • URL Spoof Issue in Search Results
            LogicalMediaGroup
            LogicalMediaGroup
            0
            5
            159

          • Are these URL hashtags an SEO issue?
            McTaggart
            McTaggart
            0
            4
            5.0k

          • How to fix issues regarding URL parameters?
            AlanMosley
            AlanMosley
            0
            8
            2.0k

          • Page URL Issue
            AdamThompson
            AdamThompson
            0
            4
            830

          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