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. I need help with a PHP canonical URL tags

    I need help with a PHP canonical URL tags

    Technical SEO Issues
    4 4 3.7k
    • 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.
    • lnietob
      lnietob last edited by

      I found a little difficult for me to do a canonical tag in my PHP.

      On-Page Report Card

      We check to make sure that IF you use canonical URL tags, it points to the right page. If the canonical tag points to a different URL, engines will not count this page as the reference resource and thus, it won't have an opportunity to rank. If you've not made this page the rel=canonical target, change the reference to this URL. NOTE: For pages not employing canonical URL tags, this factor does not apply.

      I don't know how to tidy my PHP

      Any suggestion.

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

        Hi,

        In my site, I use a php expression - as such -

        header.php -

        On page -

        $canonical = "http://www.domain.com";

        Here is a recent Blog Post if the above code does not help

        http://www.seomoz.org/blog/how-to-advanced-relcanonical-http-headers

        Shane

        ACann 1 Reply Last reply Reply Quote 1
        • Dr-Pete
          Dr-Pete last edited by

          Is this a CMS, or are you trying to make the canonical only impact certain pages or conditions? The canonical tag is just an HTML tag, in the header. It doesn't really need special code, unless the target of the canonical has to be created dynamically. Unfortunately, then the solution depends entirely on your implementation (it's not one-sized-fits-all across all PHP sites).

          If you could describe the structure of the site a bit (example URLs and how they're created) without revealing the site, that could help us pin it down.

          1 Reply Last reply Reply Quote 0
          • ACann
            ACann @Jinx14678 last edited by

            Thanks Shane,

            That was very simple and to the point.  I am doing SEO on a php site where there's a header and a footer and I didin't know how to add the canoical tag to the header correctly and the On page.  Thanks again.

            Benny

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Do you need a canonical tag for search and filter pages?
              BritneyMuller
              BritneyMuller
              0
              3
              1.2k

            • Need help please with url guidelines.
              signsny
              signsny
              0
              6
              105

            • Need help with rel canonical!
              Dr-Pete
              Dr-Pete
              0
              3
              92

            • After I 301 redirect duplicate pages to my rel=canonical page, do I need to add any tags or code to the non canonical pages?
              Mike.Goracke
              Mike.Goracke
              0
              2
              125

            • Canonical Tag - Magento - Help
              ske11
              ske11
              0
              2
              270

            • Do I need to add canonical link tags to pages that I promote & track w/ UTM tags?
              kchandler
              kchandler
              1
              5
              2.8k

            • Need Help with MAGENTO - URL rewrite
              Prime85
              Prime85
              0
              9
              1.4k

            • What is Canonical URL Tag
              alhallinan
              alhallinan
              1
              5
              1.2k

            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