Reputation: 253
I'm trying to create a sitemap for google, and I'm using php w\ a .htaccess file. I got the htaccess file to work just fine, it's my formatting in the php. Google gives me this error: Errors Unsupported file format Your Sitemap does not appear to be in a supported format. Please ensure it meets our Sitemap guidelines and resubmit.
I can't figure it out to save my life. When viewed locally it looks like it's working just fine. Here is my code:
<?php
$pictureCount = file_get_contents('http://dlolpics.com/funnyPicsHigh.html');
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset http://www.sitemaps.org/schemas/sitemap/0.9 xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
set_time_limit(0);
for($i = 1;$i <= $pictureCount;$i++){
if($i > 0 && $i < 2001){
$directory_to_use = 1;
}elseif($i > 2000 && $i < 4001){
$directory_to_use = 2;
}elseif($i > 4000 && $i < 6001){
$directory_to_use = 3;
}elseif($i > 6000 && $i < 8001){
$directory_to_use = 4;
}elseif($i > 8000 && $i < 10001){
$directory_to_use = 5;
}elseif($i > 10000 && $i < 12001){
$directory_to_use = 6;
}elseif($i > 12000 && $i < 14001){
$directory_to_use = 7;
}elseif($i > 14000 && $i < 16001){
$directory_to_use = 8;
}elseif($i > 16000 && $i < 18001){
$directory_to_use = 9;
}elseif($i > 18000 && $i < 20001){
$directory_to_use = 10;
}elseif($i > 20000 && $i < 22001){
$directory_to_use = 11;
}
echo '<url>
<loc>http://www.dlolpics.com/?p='.$i.'</loc>
<image:image>
<image:loc>http://www.dlolpics.com/images/'.$directory_to_use.'/'.$i.'.jpg</image:loc>
</image:image>
</url>';
usleep(290);
}
echo '</urlset>';
?>
Upvotes: 2
Views: 593
Reputation: 7035
$pictureCount = file_get_contents('http://dlolpics.com/funnyPicsHigh.html');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
. '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' . "\n"
. ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n";
for ($i = 0; $i < $pictureCount; $i++) {
$dir = floor($i / 2000) + 1;
$url = "http://www.dlolpics.com/images/$dir/" . ($i + 1) . '.jpg';
echo '<url>'
. '<loc>' . htmlentities($url) . '</loc>'
. '<image:image><image:loc>' . htmlentities($url) . '</image:loc></image:image>'
. "</url>\n";
}
echo '</urlset>';
Upvotes: 2