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
-
Should existing canonical tags be removed where a 301 redirect is the preferred option?
Hi, I'm working on a site that is currently using canonical tags to deal with www and non-www variations. My recommendation is to setup 301 redirects to deal with this issue instead. However, is it ok to leave the existing canonical tags in place alongside the new 301 redirects or should they be removed? My thoughts are that this is not a canonical issue and therefore they should be removed? If 301 redirects are not possible it would be better have them that nothing at all but I don't think we need both, right? Any feedback much appreciated!
Technical SEO | | MVIreland0 -
Pagination Help
Hi Moz Community, I've recently started helping a new site with their overall health and I have some pagination issues. It's an ecommerce site and they currently don't have any pagination in place except for these tags: Prev 1 2 3 ... 66 Next I understand what these are doing (leading visitors to the previous, next or last page, but do these do anything for search crawlers or does the site need to have an option of:
Technical SEO | | IceIcebaby
1.rel=next/rel=prev
2.canonical leading to the view all page (the view all page takes a long time to load) Thanks for your help. -Reed0 -
Marketing URL
Hi, I need a bit of advice on marketing URL's. The destinations URL is http://www.website.com/by-development.php?area=Isle Of Wight&development=developmentname. If we wanted to use www.website.com/developmentname on literature to send people to the ugly URL above, what would we do? Would we need to rewrite the ugly URL to the neat and then 301 the ugly to the neat? Currently, the team are using a new domain of neatandrelevant.info and 301 redirecting it to ugly URL but there are lots of different developments they want to send people to so a new domain is bought for each development which seems a bit unnecessary. They point to different pages on the ugly URL website. Assuming canonical tag would not be needed then because the ugly URL page would be redirected. Also, as the website has ugly URL's anyway, would it not be best practice to use rewrites anyway so that the URL's read www.mywebsite.com/region/development? Would it confuse things to then have extra short marketing URL's missing out /region? Hope that makes sense....
Technical SEO | | Houses0 -
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?
I have many duplicate pages. Some pages have 2-3 duplicates. Most of which have Uppercase and Lowercase paths (generated by Microsoft IIS). Does this implementation of 301 and rel=canonical suffice? Or is there more I could do to optimize the passing of duplicate page link juice to the canonical. THANK YOU!
Technical SEO | | PFTools0 -
Rel Canonical ? please help
Can some one please answer a question for me, I have a crawl error stating that I have [#### Rel Canonical 326](http://pro.seomoz.org/campaigns/243472/issues/18) Can you please advise me on how serious these Errors are? I was told by one person not to worry but It seems far to many to me. thanks
Technical SEO | | Chris__Chris0 -
Duplicate title tags and meta description tags
According to GWT, it seems that some of the pages on my website have duplicate title and meta tags. The pages identified by Google are nothing but dynamic pages: http://www.mywebsite.com/page.php
Technical SEO | | sbrault74
http://www.mywebsite.com/page.php?param=1
http://www.mywebsite.com/page.php?param=2 The thing is that I do use the canonical link tag on all pages. Should I also use the "robots noindex" tag when the page is invoked using a GET parameter? Again sorry for my english. Thank you, Stephane1 -
Help needed regarding managing client expectations - tricky situation
I will try to explain the scenario as quickly as possible and my hope is that someone can share their opinion on how they would move forward. I was introduced to a local business owner who said he wanted help with SEO. Upon looking at his current online marketing, I saw he had 2 current sites promoting the same local business (martial arts instruction / classes). Why he had two sites? He said it made it easier for him to dominate in Google. Red Flag #1. Upon doing a quick site audit, I found a ton of problems with the existing site. Black text on a black background, keyword stuffing in title tags, non-canonicalization, no xml sitemap, no Google analytics installed...on and on. In addition, the site did not really have a good look to it graphically. I told him that I recommend a fresh new site using Wordpress and that we should build the content with the focus on explaining the benefits of the classes. He agreed and we began development of a new Wordpress site from the ground up. We built a sitemap, wireframe, nice design, etc. The site looks much better and we got rid of a lot of the technical problems with the site. The problem is this: Even though the new site is technically better based on On Page analysis, it is not showing up anywhere in the Top for localized keywords. The site has been live for about 2 1/2 months (March 1). I made the mistake of telling him that in a lot of cases in the past, I was able to build a new site for other clients that would rank well for localized searches based on On Page optimization alone. This is not happening for him with the new site. The new domain is relatively new (less than a year old) and has no links at all at this point. I recommended that we do a 301 redirect from his existing domain to the new one but he is skeptical and I almost can't blame him. The client is not paying me to do any SEO. The contract was to build a new site that would be built with best SEO On Page practices (Title Tags, Header Tags, Meta Desc., XML Sitemap, canonicalization, etc.) I hesitate to post the links to his existing site and the new one we built but I can see where that may shed some more light on the subject. If interested in taking a look, please send me a message. I guess the two questions are this: 1. Is it reasonable for a site to rank well for a localized non-competitive term based on A scores of on page analysis? 2. What harm or foul is there in doing a 301 redirect from the old domain to the new one and then reverting back if he decides that the move hurt his rankings more than helped? Thanks.
Technical SEO | | bluelynxmarketing0 -
NEED HELP ASAP: SERVER ISSUE
Hey guys, Some of you may be aware of our story. We have a website about or son who was born with Down syndrome. Two days a go a post I wrote went sort of viral, and I woke up this morning to an email from my host saying they had to take my site down as an emergency because of the amount of resources it is using. So now my site is down (noahsdad.com.) ...any ideas how to proceeded? I really need to get my site back online asap. Thank you.
Technical SEO | | NoahsDad0