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
-
Canonical URL Change
Hi, I have a Product Page, say www.example.com/product-title/.
Technical SEO | | viatrading1
Canonical URL is www.example.com/product-title/ I want to change its URL to www.example.com/product-title-2/
Canonical URL is www.example.com/product-title-2/
Can't do 301 Redirect. Is SEO Juice passed from www.example.com/product-title/ to www.example.com/product-title-2/ ? Thanks,0 -
Removing a canonical tag from Pagination pages
Hello, Currently on our site we have the rel=prev/next markup for pagination along with a self pointing canonical via the Yoast Plugin. However, on page 2 of our paginated series, (there's only 2 pages currently), the canonical points to page one, rather than page 2. My understanding is that if you use a canonical on paginated pages it should point to a viewall page as opposed to page one. I also believe that you don't need to use both a canonical and the rel=prev/next markup, one or the other will do. As we use the markup I wanted to get rid of the canonical, would this be correct? For those who use the Yoast Plugin have you managed to get that to work? Thanks!
Technical SEO | | jessicarcf0 -
How is this possible? A 200 response and 'nothing' to be seen? Need help!
On checking this website http://dogtraining.org.uk/ I get a 200 response. But an Oops! Google Chrome could not find dogtraining.org.uk . Same with Firefox (Server not found). Obviously there is a problem - I just don't know where to 'start' investigating to spot the error. Can someone help me? Thank you!
Technical SEO | | patrihernandez0 -
Proxy Server & Wordpress - Need Help
I'm looking for some guidance/expert opinions on using a proxy server with Wordpress. When a consumer goes to ourwebsite.com/blog, our IT department would like to set up the request to be “proxied” to the Wordpress Blog site. They would like to add a header to the web request to identify that traffic as coming from through the proper URL. Should someone or a crawler attempt to access the WordPress site directly (blog.ourwebsite.com) they would be client side redirected to the proper URL ourwebsite.com/blog. This is WAY out of my league here, so I figured I would ask the experts. Will this negatively effect our SEO?
Technical SEO | | SavikaTilakhdin0 -
Canonical warnings
[1] My site development tool (XSP) has recently added the canonical reference as an auto-generated tag, so every page of my site now has it. Why is SEOmoz warning me that I have hundreds of pages of canonicals if it's supposed to be a GOOD thing? [2] Google is still seeing the pages without the canonical tag because that's how they were indexed. Will they eventually get purged from their index, or should I be proactive about that, and if so, how? Thanks for any input.
Technical SEO | | PatioLifeStyle0 -
Do I have a canonical problem?
Does this site www.davidclick.com have a canonical problem because the home page can be requested via 3 different urls http://www.davidclick.com/
Technical SEO | | Nightwing
http://davidclick.com/
http://www.davidclick.com/index.htm but I'm confused in terms of applying a fix for example all advice here http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139066#1 says i need to identify the duplicate files and add So my question is please if I do have a canonical problem how can i fix it when I only have one file for my home page, there are no duplicates 😞 Any insights welcome 🙂0 -
Canonical tag in preferred and duplicate page
Hi, I have a super spiffy (not) CMS that tends to create some pages at the root level of the site (not where I want it) i.e. www.site.com/page.htm as well as the desired location i.e. www.site.com/category/keyword/page.htm . Now obviously a canonical tag inserted into the URL at the undesired location would be the best option, however the source code is exactly the same for both pages (can’t change this) i.e. if I put the canonical tag that reads www.site.com/category/keyword/page.htm"/> it will appear in the head section of both pages, the desired URL and the non desired URL. Will a canonical tag inserted into the head section of a the preferred URL directing the search engine spiders pretty much to itself cause more grieft than the solution it offers re duplicate content ? Marc
Technical SEO | | NRMA0 -
Need advanced SEO help!
Hi guys, This is my last attempt to work out what is up with this site before it goes to the big Flipper in the sky (and even then I doubt it will make much more than £1!) This site was a successful site, then one day Google decided it didnt like it, and I have not had much joy with it for nearly a year now. I must admit I tried to forget about it for a while, but it has always been a thorn in my side due to the fact it used to be a nice little earner. I have SEOmoz crawled it and I cant find any issues that would cause such a severe penalty, I removed many of the affiliate links, clocked the rest of the affiliate links and tried numurous other ideas, but now, as a last ditch attempt I am looking for some help! I tried to avoid the typical thin affiliate site by adding relevant content, but I have seen sites with much poorer design and content rank higher than this one. Any ideas welcome! Thanks in advance My site
Technical SEO | | mozUser14692366292850