J’utilise avec plaisir l’excellent script e-commerce Thelia mais il m’arrive parfois de chercher certaines petites choses de manières récurrentes. Aujourd’hui j’ai cherché comment faire un sitemap.xml facilement pour le soumettre à Google Webmaster Tools. Pour ne plus oublier, je le note ici (parce-que mon blog me sert aussi de mémo) :

Créez un fichier sitemap.php :

<?php
$fond= »sitemap.html »;
$parsephp=1;
include(« fonctions/moteur.php »);
?>

Créez un fichier sitemap.html

<? echo(‘<?xml version= »1.0″ encoding= »UTF-8″?>’); ?>
<urlset xmlns= »http://www.sitemaps.org/schemas/sitemap/0.9″>
<THELIA_rub type= »RUBRIQUE »>
<url>
<loc>http://www.votredomaine.com/#REWRITEURL</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</THELIA_rub>
<THELIA_produit type= »PRODUIT »>
<url>
<loc>http://www.votredomaine.com/#REWRITEURL</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</THELIA_produit>
<THELIA_dossier type= »DOSSIER »>
<url>
<loc>http://www.votredomaine.com/#REWRITEURL</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</THELIA_dossier>
<THELIA_contenu type= »CONTENU »>
<url>
<loc>http://www.votredomaine.com/#REWRITEURL</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</THELIA_contenu>
</urlset>

et dans votre fichier .htaccess ajoutez ceci

RewriteRule ^sitemap.xml /sitemap.php  [NC,L]

Votre sitemap se trouve alors à l’adresse www.votredomaine.com/sitemap.xml et vous pouvez le soumettre dans votre console webmaster 😉