Ebin V Thomas Posted October 6, 2022 Share Posted October 6, 2022 Hello, We enabled WHMCS with fully SEO friendly URL. So when we open a KB , the URL's will be open like https://website.com/knowledgebase/254/testarticle.html We created new sitemap with all these URLs and submitted on search engine . But we can see "canonical URL" need to mention in each page code. so when we inquire, we able to understand ,if we add below mentioned code in "header.tpl" , it will fix the error . but I am worried if the "canonical URL" set is completely different with the url mentioned in sitemap , it affect our SEO. Can anyone suggest something to fix this issue. <link rel="alternate" hreflang="bg-bg" href="https://www.yourdomainname.com/kb.php?kbid={$kbid}" /> 0 Quote Link to comment Share on other sites More sharing options...
Ebin V Thomas Posted April 29, 2023 Author Share Posted April 29, 2023 No one replied yet. ! as per the support response,i created a hook and added below code. But still its not working <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { $template = $vars['$template']; $SystemURL = 'https://www.domain.com'; $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $url = strtok($url, '?'); return <<<HTML <link rel="canonical" href="{$url}"/> HTML; }); also tried the below code, still not working. can anyone help ? <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { $template = $vars['$lagom2']; $SystemURL = 'https://www.domain.com'; $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $url = strtok($url, '?'); return <<<HTML <link rel="canonical" href="{$url}"/> HTML; }); can anyone help 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted April 29, 2023 Share Posted April 29, 2023 Hello, For me, this works: <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $url = strtok($url, '?'); return <<<HTML <link rel="canonical" href="{$url}"/> HTML; }); Is there any way that I could check it personally? 0 Quote Link to comment Share on other sites More sharing options...
Ebin V Thomas Posted April 29, 2023 Author Share Posted April 29, 2023 (edited) There is a problem with that. if google crawled somehow the old non-SEO-friendly URL, it gives the wrong canonical URL. for example with knwoldeg base article: if a URL is like domain.com/clients/index.php?rp=/knowledgebase/920/test.html , then the canonical URL will be like below <link rel="canonical" href="https://www.domain.com/clients/index.php"/> . It's the wrong URL. so we need to add separate lines for KB, announcement and other system URLs in code . like below for kb : href="https://www.website.com/whmcs/knowledgebase/{$kbarticle.id}/{$kbarticle.urlfriendlytitle}.html Edited April 29, 2023 by Ebin V Thomas 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted April 29, 2023 Share Posted April 29, 2023 To fix it, it's better you activate to the Full Friendly Rewrite, check this out: https://docs.whmcs.com/Friendly_URLs 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.