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. Please let me know if I am in a right direction with fixing rel="canonical" issue?

    Please let me know if I am in a right direction with fixing rel="canonical" issue?

    Technical SEO Issues
    6 3 546
    • 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.
    • kirupa
      kirupa last edited by

      While doing my website crawl, I keep getting the message that I have tons of duplicated pages.
      http://example.com/index.php and http://www.example.com/index.php are considered to be the duplicates. As I figured out this one: http://example.com/index.php is a canonical page, and I should point out this one: http://www.example.com/index.php to it. Could you please let me know if I will do a right thing if I put this piece of code into my index.php file?
      ? Or I should use this one:

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

        Hi,

        Ideally, you would handle www and nonwww duplication by way of a redirect rule. Both versions of that URL should not render, i.e. when you go to www.example.com it should take you straight over to example.com.

        You can handle this with canonical tags the way you've proposed, the URL in the href element should be the one you prefer. However, this should be reserved only as a work-around in the event that you can't get implement a server-side redirect rule to handle ALL www-to-nonwww issues.

        kirupa 1 Reply Last reply Reply Quote 3
        • MikeRoberts
          MikeRoberts last edited by

          As Logan said, you'd be better served handling these with 301 redirects. But you will also want to go in Google Search Console/Webmaster tools into Site Settings and set your preferred domain to either WWW on Non-WWW (depending on which you prefer to show across your site).

          kirupa 1 Reply Last reply Reply Quote 2
          • kirupa
            kirupa @LoganRay last edited by

            Thanks for your reply, Logan. Why exactly 301 redirect is better than handling this with canonical tags? Canonical tags wouldn't take so much time, would they?

            LoganRay 1 Reply Last reply Reply Quote 0
            • kirupa
              kirupa @MikeRoberts last edited by

              Thank you, will do!

              1 Reply Last reply Reply Quote 0
              • LoganRay
                LoganRay @kirupa last edited by

                This type of duplicate applies to far more than just the homepage...so by implementing a single redirect rule, you handle this type of duplicate for every single URL on your site, and neither people nor search engines will ever see the undesired version.

                If you do this via canonical tags, you have to include the canonical tag on every page, which could be very time consuming depending on how large your site is.

                1 Reply Last reply Reply Quote 3
                • 1 / 1
                • First post
                  Last post
                • Meta data & xml sitemaps for mobile sites when using rel="canonical"/rel="alternate" annotations
                  Dr-Pete
                  Dr-Pete
                  0
                  2
                  714

                • Rel="canonical" again
                  socialengaged
                  socialengaged
                  0
                  12
                  257

                • Rel="canonical"
                  AndieF
                  AndieF
                  0
                  2
                  73

                • Implementation of rel="next" & rel="prev"
                  KeriMorgret
                  KeriMorgret
                  0
                  8
                  1.4k

                • Rel="canonical" and rewrite
                  webtarget
                  webtarget
                  0
                  4
                  551

                • ECommerce products duplicate content issues - is rel="canonical" the answer?
                  timhatton
                  timhatton
                  0
                  7
                  844

                • Pagination - rel="next" and rel="prev"
                  DigitalJungle
                  DigitalJungle
                  0
                  2
                  430

                • Rel="canonical" for PFDs?
                  RyanKent
                  RyanKent
                  0
                  4
                  729

                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