我有一個網站,其中包含100個HTML文件的目錄。 我希望抓取工具抓取所有html文件的目錄。 我已經添加了下面這句話對我的robots.txt:是否允許在sitemap.xml文件中使用通配符?
Allow /DirName/*.html$
有沒有什麼辦法,包括在sitemap.xml的文件目錄中的文件,以便在目錄中的所有HTML文件將抓取的? 像這樣:
<url>
<loc>MyWebsiteName/DirName/*.html</loc>
</url>
我有一個網站,其中包含100個HTML文件的目錄。 我希望抓取工具抓取所有html文件的目錄。 我已經添加了下面這句話對我的robots.txt:是否允許在sitemap.xml文件中使用通配符?
Allow /DirName/*.html$
有沒有什麼辦法,包括在sitemap.xml的文件目錄中的文件,以便在目錄中的所有HTML文件將抓取的? 像這樣:
<url>
<loc>MyWebsiteName/DirName/*.html</loc>
</url>
的sitemap protocol既不限制或允許使用通配符;說實話這是我第一次聽到這個。另外,我非常確定搜索引擎不能在站點地圖中使用通配符。
請查看Google的推薦sitemap generators。有很多工具可以讓你瞬間創建站點地圖。
它不允許使用通配符。如果您在服務器上運行php,則可以列出目錄中的所有文件,並使用DirectoryIterator自動生成sitemap.xml。
// this is assume you have already a sitemap class.
$sitemap = new Sitemap;
// iterate the directory
foreach(new DirectoryIterator('/MyWebsiteName/DirName') as $directoryItem)
{
// Filter the item
if(!$directoryItem->isFile()) continue;
// New basic sitemap.
$url = new Sitemap_URL;
// Set arguments.
$url->set_loc(sprintf('/DirName/%1$s', $directoryItem->getBasename()))
->set_last_mod(1276800492)
->set_change_frequency('daily')
->set_priority(1);
// Add it to sitemap.
$sitemap->add($url);
}
// Render the output.
$response = $sitemap->render();
// Cache the output for 24 hours.
$cache->set('sitemap', $response, 86400);
// Output the sitemap.
echo $response;