PHPBB的sitemap制作,生成有利于SEO的网址
2012-06-04 17:21
155 查看
将以下PHP文件放到你网站的根目录就OK了。
加入此sitemap的前提是,必须将PHPBB论坛的默认URL规格改成以下文件里生成的格式,这里有具体方法:/article/10556459.html
注意红色部分的代码,要改成你网站对应的内容:
<?php
// By: Arlinger On 2012-6-4
// If you have any questions, please email: Arlinger@foxmail.com
// CUSTOM INSTALLATION VARIABLES:
$subdomain='www.';
$domain=' '; //这里要改成你的网站名
$folder='/forum/'; //这里要改成你把博客所在的文件夹的名字
$urls=50000;
// Change Nothing Below Here:
$domainpath='http://'.$subdomain.$domain.$folder;
// Connect
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
// Gzip compression
if (@extension_loaded('zlib') && !headers_sent())
{
ob_start('ob_gzhandler');
}
// Send Header
header("Content-Type: text/xml;charset=iso-8859-1");
// Send initial Data
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
// Send Index
$current_time=time();
echo '<url>
<loc>'.$domainpath.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$current_time).'</lastmod>
</url>';
$urls=$urls-1;
// Send Forums
$sql = 'SELECT forum_id, forum_last_post_time FROM '.$table_prefix.'forums WHERE enable_indexing=1 LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
// Fix for parents forums showing 1969
if ($data['forum_last_post_time'] == 0) {
$data['forum_last_post_time']=$current_time;}
echo '<url>
<loc>'.$domainpath.'viewforum-'.$data['forum_id'].'.html'.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$data['forum_last_post_time']).'</lastmod>
</url>';
$urls=$urls-1;
}
$db->sql_freeresult($result);
// Send Topics
$sql = 'SELECT * FROM '.$table_prefix.'topics as t, '.$table_prefix.'forums as f WHERE t.topic_approved=1 AND t.forum_id=f.forum_id AND f.enable_indexing=1 ORDER BY t.topic_id DESC LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
echo '<url>
<loc>'.$domainpath.'viewtopic-'.$data['topic_id'].'.html'.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$data['topic_last_post_time']).'</lastmod>
</url>';
}
$db->sql_freeresult($result);
// Send Closing Tags
echo ' </urlset>';
?>
加入此sitemap的前提是,必须将PHPBB论坛的默认URL规格改成以下文件里生成的格式,这里有具体方法:/article/10556459.html
注意红色部分的代码,要改成你网站对应的内容:
<?php
// By: Arlinger On 2012-6-4
// If you have any questions, please email: Arlinger@foxmail.com
// CUSTOM INSTALLATION VARIABLES:
$subdomain='www.';
$domain=' '; //这里要改成你的网站名
$folder='/forum/'; //这里要改成你把博客所在的文件夹的名字
$urls=50000;
// Change Nothing Below Here:
$domainpath='http://'.$subdomain.$domain.$folder;
// Connect
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
// Gzip compression
if (@extension_loaded('zlib') && !headers_sent())
{
ob_start('ob_gzhandler');
}
// Send Header
header("Content-Type: text/xml;charset=iso-8859-1");
// Send initial Data
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
// Send Index
$current_time=time();
echo '<url>
<loc>'.$domainpath.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$current_time).'</lastmod>
</url>';
$urls=$urls-1;
// Send Forums
$sql = 'SELECT forum_id, forum_last_post_time FROM '.$table_prefix.'forums WHERE enable_indexing=1 LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
// Fix for parents forums showing 1969
if ($data['forum_last_post_time'] == 0) {
$data['forum_last_post_time']=$current_time;}
echo '<url>
<loc>'.$domainpath.'viewforum-'.$data['forum_id'].'.html'.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$data['forum_last_post_time']).'</lastmod>
</url>';
$urls=$urls-1;
}
$db->sql_freeresult($result);
// Send Topics
$sql = 'SELECT * FROM '.$table_prefix.'topics as t, '.$table_prefix.'forums as f WHERE t.topic_approved=1 AND t.forum_id=f.forum_id AND f.enable_indexing=1 ORDER BY t.topic_id DESC LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
echo '<url>
<loc>'.$domainpath.'viewtopic-'.$data['topic_id'].'.html'.'</loc>
<lastmod>'.date("Y-m-d\TH:i:sP",$data['topic_last_post_time']).'</lastmod>
</url>';
}
$db->sql_freeresult($result);
// Send Closing Tags
echo ' </urlset>';
?>
相关文章推荐
- [SEO]让你的Asp.Net网站自动生成Sitemap——XmlSitemap
- 分享一个在线生成站点地图SiteMap制作工具
- 分享一个在线生成站点地图SiteMap制作工具
- 制作sitemap与在线生成网站地图并提交
- [转]用宏自动生成Web.sitemap文件(ASP.NET 2.0)
- 生成Windows CE5.0和制作SDK
- 在Github制作在线简历,可生成pdf
- 朋友圈装逼高考证图片怎么在线生成制作,高考证怎么写上自己的名字?
- ASP.NET分类信息站全站制作视频教程6(AJAX+SQLITE+生成静态HTML)
- 使用Fireworks 8制作网页效果图2-生成网页[原创教程]
- 用flash制作SWC文件,生成flex自定义组件【站优教程】
- C#"CodeSmith代码批量生成模板"制作经验分享
- SEO网站优化之ASP.NET生成Google网站地图的详细代码
- 什么样的URL格式有利于SEO
- 再来个专门为google量身定做的sitemap生成代码,(可是动态的哦)
- [ASP.NET MVC]利用ASP.NET SiteMap生成与Bootstrap“兼容”菜单
- 博客开张,送上一个自动生成Web.sitemap文件的VS2005插件作为见面礼。
- 使用pdfFactory Pro制作PDF,自动生成目录书签
- 使用idsdt制作生成显卡代码的dsdt文件驱动显卡