Page 1 of 1
Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 9:17 am
by radhavallabh
Hi;
The canonical link displays as below while indexing by google.
<link rel="canonical" href="
https://www.mydomain.com/www.mydomain.com" />
But it seems not right to me... can you please help and confirm if it displays correctly dear?
If not how to fix it;
Thank you in advance
Very Warm Regds./
radhavallabh
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 2:00 pm
by burt
You do not mention what version Phoenix.
I just turned on canonical in v1.0.8.14 and it reacts with correct URLs.
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 2:06 pm
by radhavallabh
burt wrote: ↑Wed Jun 15, 2022 2:00 pm
You do not mention what version Phoenix.
I just turned on canonical in v1.0.8.14 and it reacts with correct URLs.
Sorry my version is 1.0.8.15 dear -
But mine is giving the above stated URLS;
I attach my code for convenience
Code: Select all
class ht_canonical extends abstract_executable_module {
const CONFIG_KEY_BASE = 'MODULE_HEADER_TAGS_CANONICAL_';
public function __construct() {
parent::__construct(__FILE__);
}
public function build_link() {
switch (basename(Request::get_page())) {
case 'index.php':
if (isset($GLOBALS['cPath']) && !Text::is_empty($GLOBALS['cPath'])
&& ($GLOBALS['current_category_id'] > 0)
&& ($GLOBALS['category_depth'] != 'top'))
{
$canonical = Guarantor::ensure_global('category_tree')->find_path($GLOBALS['current_category_id']);
return $GLOBALS['Linker']->build('index.php', ['view' => 'all', 'cPath' => $canonical], false);
} elseif (isset($_GET['manufacturers_id']) && !Text::is_empty($_GET['manufacturers_id'])) {
return $GLOBALS['Linker']->build('index.php', ['view' => 'all', 'manufacturers_id' => (int)$_GET['manufacturers_id']], false);
}
return $GLOBALS['Linker']->build('', [], false);
//return $GLOBALS['Linker']->build('index.php', [], false);
case 'product_info.php':
return $GLOBALS['Linker']->build('product_info.php', ['products_id' => (int)$_GET['products_id']], false);
case 'products_new.php':
case 'specials.php':
return $GLOBALS['Linker']->build(null, ['view' => 'all'], false);
default:
return $GLOBALS['Linker']->build(null, [], false);
}
}
public function execute() {
$GLOBALS['Template']->add_block('<link rel="canonical" href="' . $this->build_link() . '" />' . PHP_EOL, $this->group);
}
I am not able to figure out that why my URLS are displaying in a different manner...
Please can you help;
Thank you in advance
Very Warm Regds./
radhavallabh
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 2:24 pm
by ecartz
radhavallabh wrote: ↑Wed Jun 15, 2022 2:06 pm
Code: Select all
return $GLOBALS['Linker']->build('', [], false);
//return $GLOBALS['Linker']->build('index.php', [], false);
Well, this looks like you changed the canonical link for the front page.
Did you perhaps have it as
at one time? As that, when combined with a base href of
https://www.mydomain.com/ would give the URL you describe.
Alternately, did you make a change to Linker or Href? Because I would expect your current version to work, or at least give a different problem.
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 2:34 pm
by radhavallabh
ecartz wrote: ↑Wed Jun 15, 2022 2:24 pm
radhavallabh wrote: ↑Wed Jun 15, 2022 2:06 pm
Code: Select all
return $GLOBALS['Linker']->build('', [], false);
//return $GLOBALS['Linker']->build('index.php', [], false);
Well, this looks like you changed the canonical link for the front page.
Did you perhaps have it as
at one time? As that, when combined with a base href of
https://www.mydomain.com/ would give the URL you describe.
Alternately, did you make a change to Linker or Href? Because I would expect your current version to work, or at least give a different problem.
Yes I use a different Href dear with SEO url; But seems to work fine sitewide yet, confused to why is it causing issue with canonical...
Can there be a solution dear?
Please can you help me fix it;
Thank you in advance;
Regds./
radhavallabh
Can you help me understa
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 2:47 pm
by ecartz
Since you are already customizing that line, try
Code: Select all
return HTTP_SERVER . DIR_WS_CATALOG;
Or modify the URL rewriter to return the URL that you want.
@raiwa has a URL rewriter for sale. He might find this a reasonable configuration option (to remap a bare index.php to just the directory). Then you could use the core canonical module.
Re: Canonical Link displays incorrect
Posted: Wed Jun 15, 2022 3:00 pm
by radhavallabh
ecartz wrote: ↑Wed Jun 15, 2022 2:47 pm
Since you are already customizing that line, try
Code: Select all
return HTTP_SERVER . DIR_WS_CATALOG;
Or modify the URL rewriter to return the URL that you want.
@raiwa has a URL rewriter for sale. He might find this a reasonable configuration option (to remap a bare index.php to just the directory). Then you could use the core canonical module.
Thank you so much dear

;
Very Warm Regds./
radhavallabh