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. Rel="canonical" What if there is no header??

    Rel="canonical" What if there is no header??

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

      Hi Everyone!

      Thanks to moz.com, I just found out that we have a duplicate content issue: mywebsite.com and mywebsite.com/index.php have the same content. I would like to make mywebsite.com the main one because it already has a few links and a better page rank.

      I know how to do a 301 redirect (already have one for www.mywebsite.com) but I am aware that a 301 redirect for my index file would create a loop issue. I have read the article about redirecting without creating a loop (http://moz.com/blog/apache-redirect-an-index-file-to-your-domain-without-looping) but quite frankly I don't even have a clue what he's trying to tell me (e.g. "Create an apache DirectoryIndex directive for your document root." What????!)… So I figured a rel="canonical" tag for my index file would be easier and fix the problem, too (right??)

      In every "How to" description they always say you have to put the  rel="canonical" tag in the header of your duplicate content file. But: My index.php has no header (or nothing that looks like a header to me)! This is what it looks like:

      foreach($_GET as $key => $value)
      {
      $$key = $value;
      }
      foreach($_POST as $key => $value)
      {
      $$key = $value;
      } 
      $page_title="my title";
      $page_description="my description";
      $page_keywords="keywords";
      //echo $link;
      //exit;
      if (!isset($link)):
      $page_content="homepage.php";
      else:
      if ($link=="services"):
      $page_content="services.php";
      $page_title=" my title for services page";
      $page_description="description for services.";
      endif;
      … ect. for the other pages

      So where do I put the rel=canonical tag?

      Or is there another solution for the whole problem? Like delete the whole index file (lol)

      Thanks in advance for any answers!

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

        What is in your homepage.php file? It sounds like there could be a header from the code snippet that you've copied in.

        momof4 2 Replies Last reply Reply Quote 2
        • momof4
          momof4 @Martijn_Scheijbeler last edited by

          Hi Martijn!

          Yes there is a header in my homepage.php file. Does that help? I thought the rel=canonical tag has to go in the file you want to "redirect"?

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

            Sounds like you've got a php site that's dynamically creating pages.  You have to find the person who wrote the script and have them edit the template to add a canonical tag that inserts the correct url when the page is generated.  Your not going to be able to insert a static canonical tag.

            momof4 1 Reply Last reply Reply Quote 1
            • momof4
              momof4 @alrockn last edited by

              You are right about the site dynamically creating pages. But the only one with the duplicate content issue is the homepage. I only need a rel=canonical tag for this one

              Unfortunately contacting the people who originally wrote the code for the website and have them make changes is not an option 😞

              I will either have to figure this out on my own or find someone who can help me 😞

              1 Reply Last reply Reply Quote 0
              • momof4
                momof4 @Martijn_Scheijbeler last edited by

                Just fyi and for anyone who might be interested: That was the solution! I put the rel=canonical tag in the homepage header and my duplicate page content problem was gone!

                Thanks!!!

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • 404 or rel="canonical" for empty search results?
                  haghadi
                  haghadi
                  1
                  6
                  608

                • Link rel="prev" AND canonical
                  Everett
                  Everett
                  1
                  12
                  1.8k

                • Does rel="canonical" support protocol relative URL?
                  Cyrus-Shepard
                  Cyrus-Shepard
                  0
                  3
                  1.9k

                • Meta data & xml sitemaps for mobile sites when using rel="canonical"/rel="alternate" annotations
                  Dr-Pete
                  Dr-Pete
                  0
                  2
                  714

                • 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

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

                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