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
-
How long does it take for canonical tags to work
How long on average does it take for a canonical tag to work? Understand that canonicals are just a suggestion, but after adding a canonical tag and submitting the page via Google fetch, assuming Google follows the canonical, would you expect it to work after a day or two or does it take longer? We added canonicals to old PPC landing pages that are ranking organically, though our new landing pages (which we want to rank organically) are not identical and have a bit more content/features. They are similar though. Canonicals were added to the old pages (pointing to new pages) and requested indexing via search console. Old pages are still ranking and new pages not so much. FYI we are unable to 301 old PPC pages due to other non negotiable reasons unfortunately. Thanks.
Technical SEO | | SoulSurfer80 -
Wrong title tag
Hi, need help. I notice Google always , on all my pages (about 30), index wrong title tag. If I try to use "my-keywords-here | my_company_name" Google always index "my_company_name: my-keywords-here" and can't figure why is that :(
Technical SEO | | MirkoL
The problem is always only with "my-keywords-here | my_company_name".
If I use "my-keywords-here - my_company_name" or "my-keywords-here my_company_name" (without sign | ) everything is fine
Is anybody having any reasonable explanation?
Is anybody having Joomla page with "my-keywords-here | my_company_name" in the title and have indexed by Google like that? one example is www.ferometal-prerada.hr Thank you1 -
Need help optimizing Windows IIS server for SEO
My web site, www.nhfinehomes.com, is running on IIS7 and I did read a great post on SEOMoz.org regarding how to optimize IIS for SEO in particular, redirecting URL's to lowercase properly. However, I lack the technical skills to do this and am looking for someone who has done this before that can consult on this. Can anyone help or recommend a consultant with actual, IIS SEO experience?
Technical SEO | | LinkMoser0 -
Hash tag
We are using the hash tag on our redesign for faceted search. So, for example it will look like this www.example.com#fun123. I was looking into how i could exclude my faceted search from my robots.txt, but i was recently told I wouldnt need to do this since Googlebot doesnt index the hash tags or anything after it anyway. All of the articles I've read online do not give me a straight answer. Has google answered this one for certain? Thanks!
Technical SEO | | CHECOM0 -
Canonical Issue?
Hi, I was using the On Page Report Card Tool here on SEOMOZ for the following page: http://www.priceline.com/eventi-a-kimpton-hotel-new-york-city-new-york-ny-1614979-hd.hotel-reviews-hotel-guides and it claims there is a canonical issue or improper use of it. I looked at the element and it seems to be fine: <link rel="canonical" href="http://www.priceline.com/eventi-a-kimpton-hotel-new-york-city-new-york-ny-1614979-hd.hotel-reviews-hotel-guides" /> Can you spot the issue and how it would be fixed? Thanks. Eddy
Technical SEO | | workathomecareers0 -
URL structure
Hi, I am in the process of having a site created which will focus on the Xbox 360, PS3, Wii and PS3 Vita. I would appreciate some advice when it comes to the URL structure. Each category mentioned above will have the following subsections News
Technical SEO | | WalesDragon
Reviews
Screenshots
Trailers Would the best url structure be? www.domain.com/xbox-360/news/news-story-headline
www.domain.com/ps3/reviews/ps3-game-name Thanks in advance for your help and suggestions.0 -
HTML url extension
I've read some information about the extension of an url. But i couldn't find a clear answer. What is better for SEO, an extension with html or without? /make-money-online/how-to-make-a-million-dollars-in-1-year/ or /make-money-online/how-to-make-a-million-dollars-in-1-year.html/ Is there a difference between a normal website or a blog?
Technical SEO | | PlusPort0 -
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