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
Canonical Link displays incorrect
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Canonical Link displays incorrect
You do not mention what version Phoenix.
I just turned on canonical in v1.0.8.14 and it reacts with correct URLs.
I just turned on canonical in v1.0.8.14 and it reacts with correct URLs.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Canonical Link displays incorrect
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);
}
Please can you help;
Thank you in advance
Very Warm Regds./
radhavallabh
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Canonical Link displays incorrect
Well, this looks like you changed the canonical link for the front page.radhavallabh wrote: ↑Wed Jun 15, 2022 2:06 pmCode: Select all
return $GLOBALS['Linker']->build('', [], false); //return $GLOBALS['Linker']->build('index.php', [], false);
Did you perhaps have it as
Code: Select all
return 'www.mydomain.com';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.
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Canonical Link displays incorrect
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...ecartz wrote: ↑Wed Jun 15, 2022 2:24 pmWell, this looks like you changed the canonical link for the front page.radhavallabh wrote: ↑Wed Jun 15, 2022 2:06 pmCode: Select all
return $GLOBALS['Linker']->build('', [], false); //return $GLOBALS['Linker']->build('index.php', [], false);
Did you perhaps have it asat one time? As that, when combined with a base href of https://www.mydomain.com/ would give the URL you describe.Code: Select all
return 'www.mydomain.com';
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.
Can there be a solution dear?
Please can you help me fix it;
Thank you in advance;
Regds./
radhavallabh
Can you help me understa
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Canonical Link displays incorrect
Since you are already customizing that line, try 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.
Code: Select all
return HTTP_SERVER . DIR_WS_CATALOG;@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.
-
radhavallabh
- Senior Contributor
- Posts: 466
- Joined: Tue Oct 27, 2020 4:09 am
- Phoenix Version: 1.1.0.6
- Has thanked: 29 times
- Been thanked: 3 times
Re: Canonical Link displays incorrect
Thank you so much dearecartz wrote: ↑Wed Jun 15, 2022 2:47 pm Since you are already customizing that line, tryOr modify the URL rewriter to return the URL that you want.Code: Select all
return HTTP_SERVER . DIR_WS_CATALOG;
@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.
Very Warm Regds./
radhavallabh