/ / .htaccess prepísať sitemap php na xml - php, xml, .htaccess, mod-rewrite, prepísať

.htaccess prepísať sitemap php do xml - php, xml, .htaccess, mod-rewrite, prepísať

Chcem vytvoriť dynamiku sitemap.xml pomocou php a .htaccess z mojej databázy. Môj súbor sitemap.php:

<?
include "db.php";
header("Content-Type: text/xml;charset=iso-8859-1");
echo "<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
";

{
while($row = mysql_fetch_array($result)) {
$url = $row["url_code"];
echo "   <url>
<loc>http://domain.com/$url</loc>
</url>
";
}
}
?>
</urlset>

Mám nasledujúce .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^stats [NC]
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
Rewriterule ^sitemap.xml$ sitemap.php [L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . index.php [L]

Ale všetko, čo dostanem, je 404 nenájdená chyba. Snažil som sa len:

RewriteEngine On
Rewriterule ^sitemap.xml$ sitemap.php [L]

Ale dostať rovnakú chybu. Kde sa mýlim?

odpovede:

0 pre odpoveď č. 1

Zdá sa, že všetko funguje teraz, bez toho, aby sa niečo zmenilo! Takto to robíte


-1 pre odpoveď č. 2

skúste to:

RewriteRule ^sitemap.xml$ xmlsitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]