2013-06-27 47 views
1

我創建了一個動態網站地圖使用PHP,你可以看到我的網站地圖在這個link如何生成網站地圖,如果有很多條目?

我要去提交此鏈接到谷歌網站管理員工具,但我不知道是發佈所有地圖中1頁或本正道也許使用分頁這一點?我不知道哪種方式是正確的,但這個網站每天使500或600用戶,我認爲它不是一個正確的方式ro插入所有這些在sitemap ..現在需要幫助在這

這裏是我的代碼來創建這個網站地圖

header("Content-type: text/xml"); 
$xml = new DomDocument('1.0', 'utf-8'); 
$xml->formatOutput = true; 

// creating base node 
$urlset = $xml->createElement('urlset'); 
$urlset -> appendChild(
    new DomAttr('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9') 
); 

    // appending it to document 
$xml -> appendChild($urlset); 

// building the xml document with your website content 
foreach($content as $entry) 
{ 

    //Creating single url node 
    $url = $xml->createElement('url'); 

    //Filling node with entry info 
    $url -> appendChild($xml->createElement('loc', $entry['permalink'])); 
    $url -> appendChild($lastmod = $xml->createElement('lastmod', $entry['updated'])); 
    $url -> appendChild($changefreq = $xml->createElement('changefreq', 'monthly')); 

    // append url to urlset node 
    $urlset -> appendChild($url); 

} 

echo $xml->saveXML(); 
?> 

回答

1

Creating Sitemaps - Google Webmaster Tools

一個Sitemap文件可以包含不超過50,000個URL,並且在解壓縮時不得大於50MB。如果您的Sitemap超出此範圍,請將其分成幾個較小的Sitemaps。

如果您有多個站點地圖,您可以在Sitemap index file中列出它們,然後將Sitemap索引文件提交給Google。

+0

偉大的答案謝謝! :)生病在3分鐘內接受 – HiDd3N