Jump to content

21st Webb

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by 21st Webb

  1. Have managed to get the code submitted by thalhah to work with some minor modifications: <?php header('Content-type: application/xml; charset=utf-8') ?> <?php echo '<?xml version="1.0" encoding="UTF-8"?>' ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php // ####################### SET WHMCS ENVIRONMENT ######################## use WHMCS\ClientArea; define('CLIENTAREA', true); require_once("init.php"); require_once("includes/functions.php"); require_once("includes/clientareafunctions.php"); // ######################### CONNECT TO DATABASE ######################## $db = mysqli_connect($db_host, $db_username, $db_password, $db_name); if (mysqli_connect_errno()) { echo "Failed to connect to Database: " . mysqli_connect_error(); } $sql_whmcs = mysqli_query($db,"SELECT * FROM tblconfiguration WHERE setting='SystemURL' LIMIT 1"); $rlt_whmcs = mysqli_fetch_array($sql_whmcs); $CFG["siteurl"] = substr($rlt_whmcs["value"], 0, -1); $result = mysqli_query($db,"SELECT * FROM tblknowledgebase"); while ($data = mysqli_fetch_array($result)) { $title = str_replace(array(' ','/'), '-', $data['title']); $title = str_replace(array('?','.','[',']','"'), '', $title); echo ' <url>'."\n"; echo ' <loc>'.$CFG["siteurl"].'/knowledgebase/'.$data['id'].'/'.$title.'.html'.'</loc>'."\n"; echo ' </url>'."<br>"; }//while echo '</urlset>'."\n"; ?> Save this as sitemap.php in your WHMCS root folder within your public_html directory, i.e. public_html/whmcs/sitemap.php This will now correctly output each Knowledgebase article's URL on a separate line within XML format. You can now add the URL of your sitemap.php file to Google and Bing Webmasters as it is, no need to use a .htaccess rewrite rule to convert sitemap.xml to sitemap.php unless you really want to.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated