Location of Sitemap Files [Contents]
The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://yoursite.com/catalog/sitemap.gz can include any URLs starting with http://yoursite.com/catalog/ but can not include URLs starting with http://yoursite.com/images/.
If you have the permission to change "http://site.org/path/sitemap.gz", it is safe to assume that you also have permission to provide information for URLs with the prefix "http://site.org/path/". Examples of URLs considered valid in http://yoursite.com/catalog/sitemap.gz include:
http://yoursite.com/catalog/show?item=23
http://yoursite.com/catalog/show?item=233&user=3453
URLs not considered valid in http://yoursite.com/catalog/sitemap.gz include:
http://yoursite.com/image/show?item=23
http://yoursite.com/image/show?item=233&user=3453
http://example.com/catalog/show?item=24
URLs that are not considered valid are dropped from further consideration. It is strongly recommended that you place your Sitemap at the root directory of your web server. For example, if your HTTP Web server is at yoursite.com, then your Sitemap index file would be at "http://yoursite.com/sitemap.gz". In certain cases, you may need to produce different Sitemaps for different paths — e.g. if security permissions in your organization compartmentalize write access to different directories.
tomythius wrote:lvsinjin wrote:tomythius wrote:Mine now sits in the folder above my phpbb root, in the real root of my whole site.
A few hardcoded lines in the template means that my static pages are included in the same map.
DEMO
how is this done
Just put sitemap.php in your root and change the variables to reflect it's new location.
For instance, I changed $phpbb_root_path to 'talk/' which is the location of the phpBB root in relation to the root of my whole site.
I also had to change:toCode: Select all
$server_url = $server_protocol . $server_name . $server_port . $script_name;
because urls weren't being presented correctly.Code: Select all
$server_url = $server_protocol . $server_name . $server_port . $script_name . '/';
All the other files are in the locations described in the mod.
I added a few lines of xml to sitemap_body.tpl in order to include my regular (static) pages to the map:for example.Code: Select all
<url> <loc>http://www.tom.whaletattoo.com/</loc> <changefreq>daily</changefreq> <priority>1.0</priority> </url>
Code: Select all
INSERT INTO `phpbb_config` VALUES ('sitemap_announce_priority', '1.0');
INSERT INTO `phpbb_config` VALUES ('sitemap_default_priority', '0.5');
INSERT INTO `phpbb_config` VALUES ('sitemap_sort', 'DESC');
INSERT INTO `phpbb_config` VALUES ('sitemap_sticky_priority', '0.75');
INSERT INTO `phpbb_config` VALUES ('sitemap_topic_limit', '250');
Code: Select all
, '1'
Code: Select all
INSERT INTO `phpbb_config` VALUES ('sitemap_announce_priority', '1.0', '1');
INSERT INTO `phpbb_config` VALUES ('sitemap_default_priority', '0.5', '1');
INSERT INTO `phpbb_config` VALUES ('sitemap_sort', 'DESC', '1');
INSERT INTO `phpbb_config` VALUES ('sitemap_sticky_priority', '0.75', '1');
INSERT INTO `phpbb_config` VALUES ('sitemap_topic_limit', '250', '1');
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . "common.$phpEx");
// Begin Configuration Section
$included_forum_ids = array();
$excluded_forum_ids = array();
// End Configuration Section
if ( count($included_forum_ids) > 0 )
{
$included_forum_ids_sql = 'forum_id IN (' . implode(', ', $included_forum_ids) . ')';
}
if ( count($excluded_forum_ids) > 0 )
{
$excluded_forum_ids_sql = 'forum_id NOT IN (' . implode(', ', $excluded_forum_ids) . ')';
}
if ( ( count($included_forum_ids) > 0 ) && ( count($excluded_forum_ids) > 0 ) )
{
$and = 'AND';
}
if ( ( count($included_forum_ids) > 0 ) || ( count($excluded_forum_ids) > 0 ) )
{
$where = 'WHERE';
}
$sql = "SELECT topic_id, forum_id, topic_time, topic_type FROM " . TOPICS_TABLE . " $where $included_forum_ids_sql $and $excluded_forum_ids_sql ORDER BY topic_time DESC";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Error: could not retrive topic IDs', '', __LINE__, __FILE__, $sql);
}
$protocol = ( $board_config['cookie_secure'] == 0 ) ? 'http://' : 'https://';
$servername = $board_config['server_name'];
$port = ( $board_config['server_port'] == '80' ) ? '' : ':' . $board_config['server_port'];
$path = $board_config['script_path'];
$count1 = 1;
while ( $row = $db->sql_fetchrow($result) )
{
$count = $count +1;
if ($count == ($count1*48000))
{
$memory = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$memory .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"' . "\n";
$memory .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n";
$memory .= 'xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84' . "\n";
$memory .= 'http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">' . "\n";
$memory .= $output;
$memory .= "</urlset>\n";
$gzdata = gzencode($memory, 9);
$fp = fopen("sitemap".$count1.".xml.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
$count1 = $count1+1;
$output = "";
$memory = "";
}
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];
$lastmodified = date('Y-m-d\TG:i:s+00:00', $row['topic_time']);
$viewtopic = "/about$topic_id.html";
$priority = ( $row['topic_type'] == POST_STICKY || $row['topic_type'] == POST_ANNOUNCE ) ? '1.0' : '0.5';
$output .= "<url><loc>$protocol$servername$port$path$viewtopic</loc><lastmod>$lastmodified</lastmod><changefreq>weekly</changefreq><priority>$priority</priority></url>\n";
//header('Content-type: application/xml');
}
// write the rest
$memory = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
$memory .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";
$memory .= $output;
$memory .= "</urlset>\n";
$gzdata = gzencode($memory, 9);
$fp = fopen("sitemap".$count1.".xml.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
$output = "";
$memory = "";
$count1 = $count1+1;
//header('Content-type: application/xml');
//$count1 = $count1 -1;
$finalsm = '<?xml version="1.0" encoding="UTF-8"?>'. "\n";
$finalsm .= '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84"'. "\n";
$finalsm .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. "\n";
$finalsm .= 'xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84'. "\n";
$finalsm .= 'http://www.google.com/schemas/sitemap/0.84/siteindex.xsd">'. "\n";
$a = 1;
while ($a<$count1) {
$finalsm .= '<sitemap>'. "\n";
$finalsm .='<loc>'.$protocol.''.$servername.''.$port.''.$path.'/'."sitemap".$a.".xml.gz".'</loc>'. "\n";
$finalsm .='<lastmod>'.$lastmodified.'</lastmod>'. "\n";
$finalsm .='</sitemap>'. "\n";
$a=$a+1;
}
$finalsm .= '</sitemap></sitemapindex>';
$fp = fopen("sitemap.xml", "w");
fwrite($fp, $finalsm);
fclose($fp);
echo "<br><br>Finished gzipping!";
?>
You should refer to http://www.pentapenguin.com for supportjarosciak wrote: Hi All, not sure where to post this.
I amended original code from http://www.pentapenguin.com and added cutting of files to 49000 URLs pieces.
2005-08-08T11:34:29+00:00
2004-10-26T08:56:39+00:00