4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: khansahib on July 11, 2011, 05:48:35 PM

Title: Google Canonical
Post by: khansahib on July 11, 2011, 05:48:35 PM
Hello,

I am running 4images on my website, today i checked the Google webmaster section and i have noticed that Google is pointing many pages as duplicate, I am trying to use Google Canonical but i am unable to fix this issue. My website URL structure is as follows.

site.com/stuff/cat-nokia-7710-themes-27.htm
site.com/stuff/cat-nokia-7710-themes-27.htm?page=2
site.com/stuff/cat-nokia-7710-themes-27.htm?page=3

and so on

now I want to add Google Canonical to my first URL i.e. site.com/stuff/cat-nokia-7710-themes-27.htm

How should I do this?
Title: Re: Google Canonical
Post by: Rembrandt on July 11, 2011, 06:01:52 PM
......site.com/stuff/cat-nokia-7710-themes-27.htm
site.com/stuff/cat-nokia-7710-themes-27.htm?page=2
site.com/stuff/cat-nokia-7710-themes-27.htm?page=3
.....
copy the follow row in all  *?page=X  between <head> .....</head>:
Quote

<head>
.
.
<link rel="canonical" href="http://www.site.com/stuff/cat-nokia-7710-themes-27.htm"/>
.

</head>

mfg Andi
Title: Re: Google Canonical
Post by: khansahib on July 11, 2011, 06:43:38 PM
Well, as you know doing manually will take ages as we have categories with 100 pages, so it won't do the trick, is there anything that can be changed i mean something in functions.php?

in my opinion there should be some changes in the following in functions.php

Code: [Select]
"cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$image_row['cat_id']),
I am not sure i am right.

need your help.
Title: Re: Google Canonical
Post by: Rembrandt on July 11, 2011, 06:53:41 PM
there is no php file?:  "cat-nokia-7710-themes-27.php"
Title: Re: Google Canonical
Post by: khansahib on July 11, 2011, 07:05:10 PM
No we are using modified .htaccess here is what we have in .htaccess

Code: [Select]
# Begin search engine friendly links code
RewriteEngine On
#RewriteBase /
#Mod_bmollet : category name in URL
RewriteRule ^cat-(.*)-([0-9]+).htm categories.php?cat_id=$2&%{QUERY_STRING}
#Mod_bmollet : Image name in URL
RewriteRule ^theme-(.*)-([0-9]+).htm details.php?image_id=$2&%{QUERY_STRING}

#Mod_bmollet : This is to make search function work  ( redirect links from search results )
RewriteRule ^theme([0-9]+).search.htm details.php?image_id=$1&%{QUERY_STRING}
RewriteRule ^cat\.htm$ categories.php?%{QUERY_STRING}

RewriteRule ^postcard([a-zA-Z0-9]+)\.htm$ postcards.php?postcard_id=$1&%{QUERY_STRING}
RewriteRule ^postcard\.img([0-9]+)\.htm$ postcards.php?image_id=$1&%{QUERY_STRING}
Title: Re: Google Canonical
Post by: Rembrandt on July 11, 2011, 07:16:26 PM
I can not help you....
Title: Re: Google Canonical
Post by: khansahib on July 12, 2011, 04:51:10 AM
can anybody please help me on this? Its v.imp
Title: Re: Google Canonical
Post by: khansahib on July 14, 2011, 04:25:19 PM
is there any solution available?
Title: Re: Google Canonical
Post by: sathishIPL on July 15, 2011, 11:58:49 AM
Quote
......site.com/stuff/cat-nokia-7710-themes-27.htm
site.com/stuff/cat-nokia-7710-themes-27.htm?page=2
site.com/stuff/cat-nokia-7710-themes-27.htm?page=3

I hope the above urls with page=2 and page=3 might be from comment pagination?
Title: Re: Google Canonical
Post by: khansahib on July 15, 2011, 12:18:15 PM
Quote
......site.com/stuff/cat-nokia-7710-themes-27.htm
site.com/stuff/cat-nokia-7710-themes-27.htm?page=2
site.com/stuff/cat-nokia-7710-themes-27.htm?page=3

I hope the above urls with page=2 and page=3 might be from comment pagination?


can you please further explain your reply? I am unable to understand/.
Title: Re: Google Canonical
Post by: sathishIPL on July 15, 2011, 12:29:06 PM
Quote
site.com/stuff/cat-nokia-7710-themes-27.htm?page=2
site.com/stuff/cat-nokia-7710-themes-27.htm?page=3

I mean how this pages are coming to you .It might come if you click the pagination in the comment system?

by clicking the next page in the comment?

Title: Re: Google Canonical
Post by: khansahib on July 15, 2011, 12:36:53 PM
I have done it :)  8)
Title: Re: Google Canonical
Post by: bergblume on July 16, 2011, 03:02:51 PM
I have done it :)  8)

can you pls. let us know your solution and what you have changed in which files? thx!
Title: Re: Google Canonical
Post by: khansahib on July 16, 2011, 07:35:31 PM
Here is how its done :).

open index.php file and find

Code: [Select]
include(ROOT_PATH.'includes/page_header.php');
Paste the following just before the above line.

Code: [Select]
if(isset($_GET['page'])) {
        $site_template->register_vars("google_con_url", '<link rel="canonical" href="' . ROOT_PATH . '/' . $_SERVER['REQUEST_URI'] . '" />');
}
else {
        $site_template->register_vars("google_con_url", '');
}


and insert

Code: [Select]
{google_con_url} in header of your template. Make sure its between <head> tags.

Title: Re: Google Canonical
Post by: bergblume on July 16, 2011, 08:00:32 PM
Hi - thanx

I assume that the code is inserted in the file details.php - right?
Title: Re: Google Canonical
Post by: khansahib on July 16, 2011, 08:01:48 PM
ah sorry i didn't mentioned that its in index.php
Title: Re: Google Canonical
Post by: bergblume on July 16, 2011, 08:07:43 PM
ah sorry i didn't mentioned that its in index.php

ahhh ok, thanks!!
Title: Re: Google Canonical
Post by: wflorian on May 29, 2012, 03:10:39 PM
does not work with 4image install...

did anybody get this mod to work?
Title: Re: Google Canonical
Post by: sathishIPL on May 30, 2012, 06:20:16 AM
Hi ,

Check out this , it is working Mod

http://www.4homepages.de/forum/index.php?topic=17598.420

Best Regards,
Satz
Title: Re: Google Canonical
Post by: Geezer on October 18, 2019, 07:14:50 AM
it doesn't really work! Why? Is the code too old?

Here is how its done :).

open index.php file and find

Code: [Select]
include(ROOT_PATH.'includes/page_header.php');
Paste the following just before the above line.

Code: [Select]
if(isset($_GET['page'])) {
        $site_template->register_vars("google_con_url", '<link rel="canonical" href="' . ROOT_PATH . '/' . $_SERVER['REQUEST_URI'] . '" />');
}
else {
        $site_template->register_vars("google_con_url", '');
}


and insert

Code: [Select]
{google_con_url} in header of your template. Make sure its between <head> tags.