0
我想創建一個動態sitemap.xml
文件使用php和.htaccess
從我的數據庫。我sitemap.php文件:.htaccess重寫網站地圖php到xml
<?
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>
我有以下.htaccess
文件:
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]
但我得到的是未找到404錯誤。我試過了:
RewriteEngine On
Rewriterule ^sitemap.xml$ sitemap.php [L]
但是得到同樣的錯誤。我哪裏錯了?