如何通过PHP生成多个站点地图XML

时间:2015-08-26 12:30:02

标签: php xml .htaccess sitemap

我当前的站点地图文件是一个太大的文件,多次超过50000网址限制。我有一个" sitemap.php"它通过htaccess显示XML文件。但是,我不知道如何为每个50000 URL拆分此站点地图。貌似,我的" sitemap.php"必须处理分裂行动。

任何帮助将不胜感激......

P.S:sitemap.php的代码如下

    <?php
ob_flush();
include ("assets/php/db.php");//bağlantımızı yaptık
header('Content-type: text/xml');

    $domainadi = $_SERVER['SERVER_NAME']; //site ismini değişkene aktardık

echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
";

echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">';

$date = date("Y-m-d");

@$xml_ciktisi .= "<url><loc>http://".$domainadi."</loc><lastmod>".$date."  </lastmod><changefreq>daily</changefreq><priority>1</priority></url>";

foreach($db->query("SELECT * FROM cumleler") as $row) {

  $trsef = $row['cumle_tr'];
  $bol = explode(" ",$trsef);
  $bolSay = count($bol);

  for($a=0; $a<=$bolSay; $a++){
  $xml_ciktisi .= "<url>

                     <loc>http://".$domainadi."/ingilizce/".$bol[$a]."</loc>

                          <lastmod>".date( 'Y-m-d' )."</lastmod>

                              <changefreq>monthly</changefreq>

                              <priority>0.5</priority>

                              </url>
"; }

  }; 


@$xml_ciktisi .= "<url><loc>http://".$domainadi."</loc><lastmod>".$date."</lastmod><changefreq>daily</changefreq><priority>1</priority></url>";

foreach($db->query("SELECT * FROM cumleler") as $row) {

  $xml_ciktisi .= "<url>

                        <loc>http://".$domainadi."/ingilizce/".$row["cumle_en"]."</loc>

                          <lastmod>".date( 'Y-m-d' )."</lastmod>

                              <changefreq>monthly</changefreq>

                              <priority>0.5</priority>

                              </url>
";
   }; 


@$xml_ciktisi .= "<url><loc>http://".$domainadi."</loc><lastmod>".$date."</lastmod><changefreq>daily</changefreq><priority>1</priority></url>";

foreach($db->query("SELECT * FROM ozelders") as $row) {

  $xml_ciktisi .= "<url>

                     <loc>http://".$domainadi."/ingilizce-ozel-ders/profil/".$row["isimsef"]."</loc>

                          <lastmod>".date( 'Y-m-d' )."</lastmod>

                              <changefreq>monthly</changefreq>

                              <priority>0.5</priority>

                              </url>
";
  }; 
 $xml_ciktisi .= "</urlset>
";


 echo $xml_ciktisi;
?>

0 个答案:

没有答案
相关问题