Merhabalar aşağıdaki kodu kendinize göre düzenlerseniz istediğiniz dinamik sitemap.xml dosyanız olacaktır.Öncelikle sitemap.php adında bir php dosyası açın ve aşağıdaki kodları kendinize göre düzenleyerek yazın.
Yazılım Soru - Kod Kısmı
<?php include("vtbaglanti.php");?>
<?php header('Content-type: text/xml');?>
<?php echo
'<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'; ?>
<?php
echo
'
<url>
<loc>http://siteadresi.com/</loc>
<lastmod>'.date("Y").'-'.date("m").'-'.date("d").'T'.date("H:i:s").' 00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>
';
$query = $db->prepare("select * from blog");
$query->execute(array());
$queryfet = $querysor->fetchAll(PDO::FETCH_ASSOC);
foreach($queryfet as $querycek){
$makale_id = $querycek["makale_id"];
$makale_sef = $querycek["makale_sef"];
echo '<url>
<loc>http://siteadresi.com/makale/'.$makale_sef.'/'.$makale_id.'</loc>
<lastmod>'.date("Y").'-'.date("m").'-'.date("d").'T'.date("H:i:s").' 00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>';
}
?>
<?php echo '</urlset>'; ?>
bunları düzenleyip kaydettikten sonra .htaccess dosyanıza girip aşağıda verdiğim kodu yapıştırın.
Yazılım Soru - Kod Kısmı
RewriteRule ^sitemap.xml$ sitemap.php [NC,L]
Bunları yapıştırdıktan sonra kaydedin sonra siteadresi.com/sitemap.xml yazın bakın kontrol edin eğer hata vermemişse tebrikler artık sizinde dinamik bir sitemap.xml dosyanız oldu.Eğer hata veriyorsa buraya yazın elimden geldiğince yardımcı olmaya çalışırım.