<p id="1tgyu"><ruby id="1tgyu"><menu id="1tgyu"></menu></ruby></p>
<acronym id="1tgyu"><label id="1tgyu"></label></acronym>
<p id="1tgyu"><strong id="1tgyu"></strong></p>
    1. <pre id="1tgyu"><label id="1tgyu"><menu id="1tgyu"></menu></label></pre>
    2. <p id="1tgyu"></p>

      <table id="1tgyu"></table>

      幫助中心

      Sitemap對于搜索引擎的收錄很有用,所以每個網站需要一個sitemap.xml,那么標準格式是什么呢?用程序如何來自動生成呢?下面小孚給大家分享一下。

      Sitemap的格式是什么?如何用程序生成站點地圖

      2020-02-18

      Sitemap對于搜索引擎的收錄很有用,所以每個網站需要一個sitemap.xml,那么標準格式是什么呢?用程序如何來自動生成呢?下面小孚給大家分享一下。

      sitemap.xml文件的標準格式

      <?xml version="1.0" encoding="utf-8"?><!-- XML文件需要使用utf-8編碼--><urlset><!--這個標簽是必須的-->    <url>        <!--也是一個必填標簽,這是具體某一個鏈接的定義入口,每一條數據都要用<url>和</url>包含在里面 -->        <loc>http://www.witsups.com/news/1.html</loc>        <!--必填,具體的鏈接地址,長度不得超過256字節,如果里面有特殊符號,需要轉義(如:&轉義為&amp;)-->        <lastmod>2020-01-01</lastmod>        <!--選填標簽,用來指定該鏈接的最后更新時間,可以是日期也可以是日期加時間-->        <changefreq>daily</changefreq>        <!--選填標簽,鏈接的更新頻率:always ,hourly ,daily ,weekly ,monthly ,yearly ,never  -->        <priority>0.8</priority>        <!--選填標簽,用來指定此鏈接相對于其他鏈接的優先權比值,此值定于0.0-1.0之間-->    </url>    <url>        <loc>http://www.witsups.com/news/2.html</loc>        <lastmod>2020-02-01</lastmod>        <changefreq>daily</changefreq>        <priority>0.8</priority>    </url></urlset>?

      用PHP來生成sitemap.xml

      $sql = "SELECT * FROM " . $ZZUF->table('article') . " ORDER BY id DESC";$thread = $ZZUF->query($sql)->fetchall();// 創建一個DOMDocument對象$dom = new DOMDocument("1.0","utf-8");header("Content-Type: text/xml");// 創建根節點$root = $dom->createElement("urlset");$dom->appendChild($root);foreach($thread as $key => $row){// 建立根下子節點track$track = $dom->createElement("url");$root->appendChild($track);// 建立track節點下元素$loc = $dom->createElement("loc");$track->appendChild($loc);$priority = $dom->createElement("priority");$track->appendChild($priority);$lastmod = $dom->createElement("lastmod");$track->appendChild($lastmod);$changefreq = $dom->createElement("changefreq");$track->appendChild($changefreq);// 獲取到域名$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://": "http://";$url = $protocol . $_SERVER['HTTP_HOST'];// 賦值$text = $dom->createTextNode($url.'/news/'.$row["id"].'.html');$loc->appendChild($text);$date = date("Y-m-d",time());$text = $dom->createTextNode($date);$lastmod->appendChild($text);$text = $dom->createTextNode(daily);$changefreq->appendChild($text);$text = $dom->createTextNode(0.8);$priority->appendChild($text);}//生成xml文件,路徑根據自己情況而定$dom->save("sitemap.xml");exit(json_encode(array("state" => 1, "msg" => "新的Sitemap已經生成")));


      如沒特殊注明,文章均為友孚原創,轉載請注明來自:http://www.witsups.com/news/7.html

      日本乱理伦片在线观看a片_97韩剧网手机版高清_99久久亚洲综合精品网站_欧美黑猛男与女人性爱视频

      <p id="1tgyu"><ruby id="1tgyu"><menu id="1tgyu"></menu></ruby></p>
      <acronym id="1tgyu"><label id="1tgyu"></label></acronym>
      <p id="1tgyu"><strong id="1tgyu"></strong></p>
      1. <pre id="1tgyu"><label id="1tgyu"><menu id="1tgyu"></menu></label></pre>
      2. <p id="1tgyu"></p>

        <table id="1tgyu"></table>