- // begin xml content
- $XML_Content = '<urlset xmlns:xsi=
- "http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.fem14.tr.gg/schemas/sitemap/0.9 '."\\n".
- 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
- xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\\n";
- foreach ($urllist as $url){ // $urllist= your website urls
- // defaults
- $date = date('Y-m-d');
- $freq = 'monthly';
- $priority = '0.5';
- // setting values
- if( is_array($url) ){
- // custom params
- if( $url[date] ) $date = $url[date];
- if( $url[freq] ) $freq = $url[freq];
- if( $url[priority] ) $priority = $url[priority];
- $url = $url[url];
- }else{
- $url = $url;
- }
- // adding to xml content
- $XML_Content .= "\\t<url>\\n".
- "\\t\\t<loc>$url</loc>\\n".
- "\\t\\t<lastmod>$date</lastmod>\\n".
- "\\t\\t<changefreq>$freq</changefreq>\\n".
- "\\t\\t<priority>$priority</priority>\\n".
- "\\t</url>\n";
- }
- $XML_Content .= "</urlset>";
- $file = fopen('sitemap.xml', 'w') )
- fwrite($file, $XML_Content);
- fclose($file);
sitemap.xml(output)
- <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.fem14.tr.gg/schemas/sitemap/0.9
- http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
- xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
- <url>
- <loc>http://www.yourdomainname.com/adres1</loc>
- <lastmod>2007-10-10</lastmod>
- <changefreq>daily</changefreq>
- <priority>0.9</priority>
- </url>
- <url>
- <loc>http://www.yourdomainnam.com/adres2</loc>
- <lastmod>2007-10-10</lastmod>
- <changefreq>monthly</changefreq>
- <priority>0.5</priority>
- </url>
- </urlset>
Hiç yorum yok:
Yorum Gönder