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. On-Page / Site Optimization
    4. Correct .htaccess settings for canonical url?

    Correct .htaccess settings for canonical url?

    On-Page / Site Optimization
    5 2 233
    • 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.
    • webbutler13
      webbutler13 last edited by

      I want to forward all urls to http:www.mysite.com but am a little confuse because I am getting duplicate content error:

      Pages with Duplicate Page Content

      as of Jan 15http://titanappliancerepair.com/ 1 duplicatehttp://titanappliancerepair.com 1 duplicatehttp://titanappliancerepair.com/index.html 1 duplicate*****************************************************************What should I put ion htaccess file so I can forwardhttp://titanappliancerepair.com/index.htmlhttp://titanappliancerepair.comhttp://titanappliancerepair.com/to  http://www.titanappliancerepair.comor what is the correct way to do it?I'm confused because when I enter http://titanappliancerepair.com/ in browser it showshttp://titanappliancerepair.com so how can it be considered duplicate content?.Can someone help?I have godaddy and they have gave me this code to put RewriteEngine on
      rewritecond %{http_host} ^coolexample.com [nc]
      rewriterule ^(.
      )$ http://www.coolexample.com/$1 [r=301,nc]What is correct?

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

        This is what I have so far in htaccess file

        RewriteEngine on
        rewritecond %{http_host} ^titanappliancerepair.com [nc]
        rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

        RewriteEngine on
        rewritecond %{http_host} ^coolexample.com/ [nc]
        rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

        RewriteEngine on
        rewritecond %{http_host} ^coolexample.com/index.html [nc]
        rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

        RewriteEngine on
        rewritecond %{http_host} ^www.titanappliancerepair.com/index.html [nc]
        rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

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

          It looks like you are redirecting any URL back to itself.

          You want something like this which will remove index.html and enforce a trailing slash-

          RewriteRule ^(.*)/index.html$ /$1/ [R=301,L]

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

            Ok I have added this to htaccess file and everything seems to be redirecting in browser ok but is it good enough for google?

            Can someone check and tell me if it is correct , if not can you help with code? Thanks in advance!

            RewriteEngine on
            rewritecond %{http_host} ^titanappliancerepair.com [nc]
            rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

            RewriteEngine on
            rewritecond %{http_host} ^titanappliancerepair.com/ [nc]
            rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

            RewriteEngine on
            rewritecond %{http_host} ^titanappliancerepair.com/index.html [nc]
            rewriterule ^(.*)$ http://www.titanappliancerepair.com/$1 [r=301,nc]

            RewriteEngine on
            RewriteBase /

            redirect html pages to the root domain

            rewriterule ^index.html$ / [r=301,nc]

            MickEdwards 1 Reply Last reply Reply Quote 0
            • MickEdwards
              MickEdwards @webbutler13 last edited by

              your directories have duplication.  For example: http://www.titanappliancerepair.com/about-us.html and http://www.titanappliancerepair.com/about-us

              You may also need   RewriteRule ^(.*).html$ /$1 [R=301**,**L]

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              • Canonical URL Tag Usage
                Andy.Drinkwater
                Andy.Drinkwater
                0
                9
                114

              • Canonical URL Category and Tags
                GPainter
                GPainter
                0
                2
                634

              • I'm using Canonical URL but still receiving message - Appropriate Use of Rel Canonical
                KeriMorgret
                KeriMorgret
                0
                7
                85

              • Is it redundant to include a redirect to my canonical domain (www) in my .htaccess file since I already have the correct rel="canonical" in my header?
                jesse-landry
                jesse-landry
                0
                4
                224

              • Can Sitemap Be Used to Manage Canonical URLs?
                ThompsonPaul
                ThompsonPaul
                0
                2
                167

              • Recommendation: Add a canonical URL tag referencing this URL to the header of the page.
                ThompsonPaul
                ThompsonPaul
                0
                7
                1.5k

              • Canonical URLs and SEO
                Nobody1560986989723
                Nobody1560986989723
                0
                16
                1.3k

              • Which Canonical URL Tag tag should we remove?
                evolvingSEO
                evolvingSEO
                0
                4
                545

              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