I need help with a PHP canonical URL tags
-
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.
-
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
-
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.
-
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
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
-
Trailing slash URLs and canonical links
Hi, I've seen a fair amount of topics speaking about the difference between domain names ending with or without trailing slashes, the impact on crawlers and how it behaves with canonical links.
Technical SEO | | GhillC
However, it sticks to domain names only.
What about subfolders and pages then? How does it behaves with those? Say I've a site structured like this:
https://www.domain.com
https://www.domain.com/page1 And for each of my pages, I've an automatic canonical link ending with a slash.
Eg. rel="canonical" href="https://www.domain.com/page1/" /> for the above page. SEM Rush flags this as a canonical error. But is it exactly?
Are all my canonical links wrong because of that slash? And as subsidiary question, both domain.com/page1 and domain.com/page1/ are accessible. Is it this a mistake or it doesn't make any difference (I've read that those are considered different pages)? Thanks!
G0 -
Link Building - Blogger Outreach - Need Help!
I am looking forward to create a solid link building campaign for my affiliate blog. But, what I want is completely GENUINE and effective link building. Could anyone please suggest what strategies should I opt for. I am planning to get Guest Blogging done? But, is it effective anymore. I have read so much about companies posting on Private networks.
Technical SEO | | scott_eastman
Are there actually companies out there that actually outreach blogs? it would be helpful if somebody could refer based upon personal experience. Much Appreciated!1 -
Need URL structure suggestions
On my website I am in the process of creating expat city guides for different cities in Cambodia. I've already gotten three up, but I am worried that my URL structure is not the best, so I am wondering if I should fix it before I put the rest up. Right now the city guides are housed here: movetocambodia.com/expat-city-and-island-guides/ There's a section for each city, this one is for Battambang: movetocambodia.com/expat-city-and-island-guides/battambang And then there are sections for hotels, restaurants, etc. movetocambodia.com/expat-city-and-island-guides/battambang/battambang-hotels-and-accommodation So once you finally get to a review for an individual hotel or activity, the URL is really long, like this: movetocambodia.com/expat-city-and-island-guides/battambang/battambang-hotels-and-accommodation/classy-hotel Should I just par the section names down so the URL would be something like this: movetocambodia.com/expat-city-guides/battambang/accommodation/classy-hotel/ ? I was hoping by having the long URLs slugs for my section pages, such as "battambang-hotels-and-accommodation" they would be more likely to show on search terms like "Battambang hotels" than if the section was just "accommodation." However, this whole section is getting much less search traffic than anything else on my site, so I am wondering if it is because of these ridiculously long URLs. Any suggestions would be appreciated.
Technical SEO | | Lina5000 -
Why put rel=canonical to the same url ?
Hi all. I've heard that it's good to put the link rel canonical in your header even when there is no other important or prefered version of that url. If you take a look at moz.com and see the code, you'll see that they put the <link rel="<a class="attribute-value">canonical</a>" href="http://moz.com" /> ... pointing at the same url ! But if you go to http://moz.com/products/pricing for example, they have no canonical there ! WHY ? Thanks in advance !
Technical SEO | | Tintanus0 -
I really need some help with Magento and Duplicate Page Content results I;m getting
Hi, We use Magento for our eCommerce platform and I'm getting a number of duplicate page content results. It mainly concerns the duplicate page content errors for our category pages. Firstly It seems like the product type and filter options highlighted in the picture are causing duplicate page content Also one particularity category is getting a lot from duplicate page content errors , http://www.tidy-books.co.uk/shop-all-products I understand that this category page is using duplicate pages of other category pages so I set this to exclude them from the site map but it looks likes its till being picked up? I've attached the csv file showing these errors as well. - > Any help would be massively appreciated Thanks filter.png moz-tidy-books-uk-crawl_issues-01-OCT-2014.csv
Technical SEO | | tidybooks0 -
Canonical: Is this a problem?
Hi!!
Technical SEO | | petrospan
I am running a small wordpress website and i have a question because i am a litle confusic about Rel Canonical notices in the crawl diagnostics! I have the seo by yoast and i have fix all the canonical url for my page, but i take notices. I must worried about it or is something that inform me that everyting is ok? rel.jpg rel.jpg0 -
Should we block URL param in Webmaster tools after URL migration?
Hi, We have just released a new version of our website that now has a human readable nice URL's. Our old ugly URL's are still accessible and cannot be blocked/redirected. These old URL's use a URL param that has an xpath like expression language to define the location in our catalog. We have about 2 million pages indexed with this old URL param in it while we have approximately 70k nice URL's after the migration. This high number of old URL's is due to facetting that was done using this URL param. I wonder if we should now completely block this URL param from Google Webmaster tools so that these ugly URL's will be removed from the Google index. Or will this harm our position in Google? Thanks, Chris
Technical SEO | | eCommerceSEO0 -
Help with Rel Canonical on Wordpress?
Crawl Diagnostics is showing a lot of Rel Canonical warnings, I've installed Wordpress SEO by Joose De Valk and Home Canonical URL plugins without success. Any ideas? I'm getting a lot of URL's that I thought I blocked from being indexed, such as author pages, category pages, etc. I'm also getting stuff like "recessionitis.com/?homeq=recent" and "recessionitis.com/page/2/", those pages are similar to my homepage. I thought those plugins were suppose to automatically clean things up.. anyone use these plugins that have any helpful hints?
Technical SEO | | 10JQKAs0