Jump to content

XML/PHP Sitemaps using rewritten htmls


iceblox

Recommended Posts

This is the full code

[code<?
$siteUrl = "http://www.thisurl.com/";

//Change below to all the pages of your website that you want inluded in your google sitemap, Then after the =>, insert the update frequency of that page.
//They must be in single quotes seperated by commas and relative to your site root......
//eg. if the file is http://www.webhostingelite.com/contactform/contact.php, you would write "contactform/contact.php"
//The order you place the values, the higher the priority it will be.
$pages = array('' => 'daily','mobile-phone-deals/' => 'daily', 'Nokia-N95-Reviews-1.html' => 'daily');



//Initialize the xml
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">";

//Scroll through the pages
$count = 0;
foreach ($pages as $page => $freq) {
if (file_exists($_SERVER['DOCUMENT_ROOT']."/".$page)) {

	$time = date('Y-m-d',filemtime($_SERVER['DOCUMENT_ROOT']."/".$page));

	$xml .= "<url>\n";
	$xml .= "<loc>{$siteUrl}{$page}</loc>\n";
	$xml .= "<lastmod>{$time}</lastmod>\n";
	$xml .= "<changefreq>{$freq}</changefreq>\n";
	if ($count < 3) {
		$min = "0.";
		$min .= $count*2;
		$priority = number_format(1.0 - $min,1,".",",");
	} else {
		$priority = 0.5;
	}
	$xml .= "<priority>$priority</priority>";
	$xml .= "</url>\n";

}
$count++;
}
$xml .=  "</urlset>";

header ("content-type: text/xml");
echo $xml;
?>

 

So what i meant was i have a page lets say Nokia-N95-Reviews-1.html which is actually phones.php?modid=1 i put the re written url into the array and nothing shows up..

 

 

Im not sure why?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.