Hi all,
A former mod of Sitemap for SMF does not get accepted by Google Webmasters Site when I want to submit it, because it has no acceptable file format for spiders to access. Its something like this http://yoursite.com/index.php?action=kitsitemap;xml
Now a coded a piece of PHP to create a sitemap containing boards and topic links only and acceptable by Google, just copy the below code and save as sitemap.php
Edit the Mysql details and save
I don't know how to create SMF mod, I would have created a mod for it
Run http://yoursite.com/sitemap.php
Hope it helps!
A former mod of Sitemap for SMF does not get accepted by Google Webmasters Site when I want to submit it, because it has no acceptable file format for spiders to access. Its something like this http://yoursite.com/index.php?action=kitsitemap;xml
Now a coded a piece of PHP to create a sitemap containing boards and topic links only and acceptable by Google, just copy the below code and save as sitemap.php
<?php/*Sitemap for SMF written by DON JAJOhttp://2netlodge.com*/$dbhost = "";//your database host, usually "localhost" in many servers$dbname = "";// your SMF database name$dbuser = "";// your SMF database user or username$dbpwd = "";// your SMF database password$siteurl = "http://yoursite.com/";// your site URL with trailing slash (eg http://yoursite.com/)//Connection to database done!$connect = mysql_connect($dbhost,$dbuser,$dbpwd)or die(mysql_error());//I selected database namemysql_select_db($dbname);//Configuring headersheader("Content-type: text/xml");echo<?xml version=1.0 encoding=UTF-8?>';echo' <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';?><?php//querying for board ids in the database$boards = mysql_query("select * from smf_boards")or die(mysql_error());while($row = mysql_fetch_array($boards)){$boardid = $row['id_board'];//Outputing?><url><loc><?=$siteurl?>index.php?board=<?=$boardid?>.0</loc></url><?php}//querying for topic ids in the database$topics = mysql_query("select * from smf_topics")or die(mysql_error());while($row2 = mysql_fetch_array($topics)){$topicid = $row2['id_topic'];//Outputing?><url><loc><?=$siteurl?>index.php?topic=<?=$topicid?>.0</loc></url><?php}?></urlset>
Edit the Mysql details and save
NOTE: If your table prefix is not smf_ please change it from the query
I don't know how to create SMF mod, I would have created a mod for it
Run http://yoursite.com/sitemap.php
Hope it helps!
No comments:
Post a Comment