Rel="canonical" What if there is no header??
-
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 pagesSo 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!
-
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!!!
-
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
-
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.
-
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"?
-
What is in your homepage.php file? It sounds like there could be a header from the code snippet that you've copied in.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
SEO Troubleshooting? Not ranking in Top 50 for "easy" keyword
Hi there, First of all, thank you in advance to whoever steps in to help me with this issue! So, I have a new site (launched December 2016) in the investing space and have been able to get page 1 rankings on some of my pages. One of my best ranking pages is for the phrase "what is xiv". The Keyword Explorer has this phrase at a 21 difficulty. My page for this keyword is https://www.projectoption.com/what-is-xiv/. The post reached the first page almost immediately after being published, though I know I shouldn't expect this for other keywords of similar difficulty. Here is my problem: I just wrote a comprehensive guide (8,000+ words) on a different keyword phrase: "vertical spreads." The Keyword Explorer has this phrase at a 25 difficulty. My page for this topic: https://www.projectoption.com/vertical-spreads-explained/. However, the page is nowhere to be found in organic Google rankings (not in top 50), and the page has been live for a few weeks now. I've done my best at optimizing the post, but something leads me to believe there are some issues that are beyond my SEO knowledge. For example, maybe the post is too long, and Google can't figure out what the page is about. Any insights would be greatly appreciated. Thank you in advance for your time! -Chris
Technical SEO | | cbutler222930 -
"Equity sculpting" with internal nofollow links
I’ve been trying a couple of new site auditor services this week and they have both flagged the fact that I have some nofollow links to internal pages. I see this subject has popped up from time to time in this community. I also found a 2013 Matt Cutts video on the subject: https://searchenginewatch.com/sew/news/2298312/matt-cutts-you-dont-have-to-nofollow-internal-links At a couple of SEO conferences I’ve attended this year, I was advised that nofollow on internal links can be useful so as not to squander link juice on secondary (but necessary) pages. I suspect many websites have a lot of internal links in their footers and are sharing the love with pages which don’t really need to be boosted. These pages can still be indexed but not given a helping hand to rank by strong pages. This “equity sculpting” (I made that up) seems to make sense to me, but am I missing something? Examples of these secondary pages include login pages, site maps (human readable), policies – arguably even the general contact page. Thoughts? Regards,
Technical SEO | | Warren_Vick
Warren1 -
What is the recommended or "best practice" Permalink Structure?
I have always been under the impression that by connecting pages to their parent pages as described in a.) below is best practice and makes sense to me. a.) yoursite.com/category/sub-category/product/ b.) yoursite.com/product But then i also understand the importance in terms of link juice being spread out across so many sub pages, and by using Example b.) you keep the link juice in tact. Your thoughts on this? Greg
Technical SEO | | AndreVanKets0 -
Canonical and Alternate REL
Hi I have a website which is mostly dynamic content from a database. In the header of the site I have a function which outputs the rel="canonical" link and in some cases the canonical is the page the user is visiting and not another page on the site but I still show it in the source. However we have just recently launched our mobile website which is stored on an M DOT domain (i.e. m.mydomain.com) which has different URL's to my main website so following Google's recommendations we have created rel="alternate" links on my desktop site to point to the equivalent mobile pages and on the mobile pages I have created rel="canonical" links which point back to the relevant desktop site keeping everything tidy.
Technical SEO | | yousayjump
My question is, is there an issue with having both a rel="canonical" and rel="alternate" in the source of of a single page on my desktop site? Is it conflicting or detrimental in anyway? Thanks for reading0 -
Canonical tags
How hard is it to put in Canonical tags on a webpage? My web guy didn't do it because he put in redirects in place for all old URLs and all content
Technical SEO | | Boodreaux
(except error pages and advanced searches) should have a unique URL. By not having canonical tags does it lose link juice? Not sure if that question makes sense. 🙂 Poo1 -
Does Google follow links in "id" tag?
Hello, For functionality purposes, I need to wrap separate blocks of content with a tag. The main question is whether Google will follow this URL, even though it is not a hyperlink on the page, just a URL used for functionality purposes. We will have 10-20 of these types of span tags with a different URL for each one, and we just want to be sure that Google will not be following these URLs that are not links. Thanks!
Technical SEO | | Hakkasan0 -
Domain with or without "www"
Does it influence the search engine result if we have our domain name without the "www." ?
Technical SEO | | netbuilder0 -
Rel=Canonical to Rewrite or original URL?
Working with a large number of duplicate pages due to different views of products. Rewriting URLs for the most linked page. Should rel=canonical point to the rewritten URL or the actual URL? Is there a way to see what the rewritten URL is within the crawl data? I was taking the approach of rewriting only the base version of each page and then using a rel=canonical on the duplicate pages. Can anyone recommend a better or cleaner approach? Haven't seen too many articles on retail SEO when faced with a less than optimized CMS. Thanks!
Technical SEO | | AmsiveDigital0