diff --git a/.htaccess b/.htaccess index 65c0f311..159ec224 100644 --- a/.htaccess +++ b/.htaccess @@ -24,6 +24,7 @@ ErrorDocument 404 /404.php RewriteRule ^reply$ reply.php [L] RewriteRule ^robots.txt$ robots.php [L] RewriteRule ^settings$ settings.php [L] + RewriteRule ^sitemap-(topics|pages|tags|users|index)(-([0-9]+))?.xml$ sitemap.php?action=$1&page=$3 [L] RewriteRule ^t/([0-9]+)(-([0-9]*))?$ topic.php?id=$1&page=$3 [L] RewriteRule ^tag/(.*?)(/page/([0-9]*))?$ tag.php?name=$1&page=$3 [L] RewriteRule ^tags/following(/page/([0-9]*))?$ favorite_tags.php?page=$2 [L] diff --git a/httpd.ini b/httpd.ini index b3f2d75a..ea104336 100644 --- a/httpd.ini +++ b/httpd.ini @@ -14,6 +14,7 @@ RewriteRule ^(.*)/register $1/register.php RewriteRule ^(.*)/reply $1/reply.php RewriteRule ^(.*)/robots.txt $1/robots.php RewriteRule ^(.*)/settings $1/settings.php +RewriteRule ^(.*)/sitemap-(topics|pages|tags|users|index)(-([0-9]+))?.xml $1/sitemap.php\?action=$2&page=$4 RewriteRule ^(.*)/t/([0-9]+)(-([0-9]*))? $1/topic.php\?id=$2&page=$4 RewriteRule ^(.*)/tag/([^/]*)(/page/([0-9]*))? $1/tag.php\?name=$2&page=$4 RewriteRule ^(.*)/tags/following(/page/([0-9]*))? $1/favorite_tags.php\?page=$3 diff --git a/install/htaccess.tpl b/install/htaccess.tpl index a1b077e4..e5ef3f8d 100644 --- a/install/htaccess.tpl +++ b/install/htaccess.tpl @@ -24,6 +24,7 @@ ErrorDocument 404 {{WebSitePath}}404.php RewriteRule ^reply$ reply.php [L] RewriteRule ^robots.txt$ robots.php [L] RewriteRule ^settings$ settings.php [L] + RewriteRule ^sitemap-(topics|pages|tags|users|index)(-([0-9]+))?.xml$ sitemap.php?action=$1&page=$3 [L] RewriteRule ^t/([0-9]+)(-([0-9]*))?$ topic.php?id=$1&page=$3 [L] RewriteRule ^tag/(.*?)(/page/([0-9]*))?$ tag.php?name=$1&page=$3 [L] RewriteRule ^tags/following(/page/([0-9]*))?$ favorite_tags.php?page=$2 [L] diff --git a/robots.php b/robots.php index f36e48d5..a4839c4c 100644 --- a/robots.php +++ b/robots.php @@ -22,13 +22,18 @@ //Crawl-delay: 1 $CurHost = 'http://'.$_SERVER['HTTP_HOST']; $ItemPerSitemap = 30000; +//sitemap 索引 +echo 'Sitemap: ',$CurHost,"/sitemap-index.xml\n"; //帖子 for($i = 1; $i <= ceil($Config['NumTopics']/$ItemPerSitemap); $i++) echo 'Sitemap: ',$CurHost,'/sitemap-topics-',$i,".xml\n"; +//帖子页 for($i = 1; $i <= ceil(ceil($Config['NumTopics']/$Config['TopicsPerPage'])/$ItemPerSitemap); $i++) echo 'Sitemap: ',$CurHost,'/sitemap-pages-',$i,".xml\n"; +//话题 for($i = 1; $i <= ceil($Config['NumTags']/$ItemPerSitemap); $i++) echo 'Sitemap: ',$CurHost,'/sitemap-tags-',$i,".xml\n"; +//用户 for($i = 1; $i <= ceil($Config['NumUsers']/$ItemPerSitemap); $i++) echo 'Sitemap: ',$CurHost,'/sitemap-users-',$i,".xml\n"; ?> diff --git a/sitemap.php b/sitemap.php new file mode 100644 index 00000000..9cfa18a6 --- /dev/null +++ b/sitemap.php @@ -0,0 +1,108 @@ + +'; +else + $MobileTag = ''; +switch ($Action) { + case 'topics': + ?> + + + + + + + 1.0 + + query('SELECT `ID`, `LastTime`, `Replies` FROM '.$Prefix.'topics force index(LastTime) WHERE IsDel=0 ORDER BY LastTime DESC LIMIT '.($Page-1)*$ItemPerSitemap.','.$ItemPerSitemap); + foreach ($TopicsArray as $Topic) {?> + + + + + 0.=70?'8':ceil(($Topic['Replies']+10)/10); ?> + + + + + + + + + 0.3 + + + + + query('SELECT `Name`, `MostRecentPostTime`, `TotalPosts` FROM '.$Prefix.'tags force index(PRI) ORDER BY ID DESC LIMIT '.($Page-1)*$ItemPerSitemap.','.$ItemPerSitemap); + foreach ($TagsArray as $Tags) {?> + + + + + 0.=50?'6':ceil(($Tags['TotalPosts']+10)/10); ?> + + + + + query('SELECT `UserName`, `Topics`, `Replies`, `LastPostTime` FROM '.$Prefix.'users force index(PRI) WHERE UserAccountStatus=1 ORDER BY ID DESC LIMIT '.($Page-1)*$ItemPerSitemap.','.$ItemPerSitemap); + foreach ($UsersArray as $User) {?> + + + + + 0.=40?'5':ceil(($User['Topics']+$User['Replies'])/10); ?> + + + + + ',$CurHost,'/sitemap-topics-',$i,".xml\n"; + //帖子页 + for($i = 1; $i <= ceil(ceil($Config['NumTopics']/$Config['TopicsPerPage'])/$ItemPerSitemap); $i++) + echo '',$CurHost,'/sitemap-pages-',$i,".xml\n"; + //话题 + for($i = 1; $i <= ceil($Config['NumTags']/$ItemPerSitemap); $i++) + echo '',$CurHost,'/sitemap-tags-',$i,".xml\n"; + //用户 + for($i = 1; $i <= ceil($Config['NumUsers']/$ItemPerSitemap); $i++) + echo '',$CurHost,'/sitemap-users-',$i,".xml\n"; + ?> + \ No newline at end of file