DennisHermannsen 109 Posted March 10, 2022 Let's say you have a knowledgebase article with the following URL: https://example.com/whmcs/knowledgebase/1/Create-a-backup.html Nothing prevents anyone from linking to that page with any text, which can cause problems. Anyone could link to https://example.com/whmcs/knowledgebase/1/WHMCS-should-fix-this.html, and it would show the correct knowledgebase article, but the URL would show as "https://example.com/whmcs/knowledgebase/1/WHMCS-should-fix-this.html" instead of redirecting to the correct URL. I made this hook a while back and thought that other people might find it useful. <?php add_hook('ClientAreaPageKnowledgebase', 1, function ($vars) { // Get the current URL and create the URL that should be redirected to $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $trueURL = $vars['systemsslurl'] . 'knowledgebase/' . ($vars['kbcurrentcat']['id'] ? $vars['kbcurrentcat']['id'] : $vars['kbarticle']['id'] ). '/' . urlencode($vars['kbcurrentcat']['urlfriendlyname'] ? $vars['kbcurrentcat']['urlfriendlyname'] : $vars['kbarticle']['urlfriendlytitle']. '.html') ; // Only redirect if visitor is viewing a knowledgebase category or an article if (($vars['templatefile'] === 'knowledgebasecat' || $vars['templatefile'] === 'knowledgebasearticle') AND strpos($url,'search') === false AND strpos($url,'tag') === false) { if ($trueURL !== $url) { header('Location: ' . $trueURL); exit(); } } }); Feel free to use it or modify it how you'd like. 0 Quote Share this post Link to post Share on other sites
Newton 0 Posted February 22 Thanks for this hook. I cannot believe WHMCS hasn't fixed that yet 😕 0 Quote Share this post Link to post Share on other sites