2016-04-01 9 views
1

私はGoogleのためにページhttp://omenorpreco.com/sitemap_index.xmlを作成し、すべてのマイページを識別します。php xmlコードを作成してブラウザをHTMLで開く

このページにアクセスすると、xmlモードでXMLが開かれません。間違って何

私はこのページのソースを表示する場合、brownserの私のデスクトップおよび開い上のファイルにコピーして、過去、このファイルを開いて、正しく

<?php 
    echo "<?xml version='1.0' encoding='UTF-8'?>";?> 
     <sitemapindex 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/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
<?php 
     header("Content-Type: application/xml; charset=UTF-8"); 
     $sql = "SELECT ceil(count(*)/5000) as total FROM `produto_price`"; 
     $result = mysql_query($sql); 
     $row = mysql_fetch_array($result); 
?> 
     <sitemap> 
      <loc>http://omenorpreco.com/sitemap-categoria.xml</loc> 
      <lastmod><?php echo date('Y-m-d'); ?></lastmod> 
     </sitemap> 
<?php 
     for($i = 1; $i <= $row['total']; $i++) : ?> 
      <sitemap> 
       <loc>http://omenorpreco.com/sitemap-<?php echo $i ; ?>.xml</loc> 
       <lastmod><?php echo date('Y-m-d'); ?></lastmod> 
      </sitemap> 
<?php 
     endfor 
?> 
    </sitemapindex> 

私の.htaccessファイルが

そしてurl_amigavel.phpをurl_amigavel.phpにリダイレクト

+4

ヘッダを試してみてください、次に出力。 – fusion3k

+0

@ fusion3kそれを答えとして追加して、私はそれをアップヴォートすることができます。 – Asaph

+1

[PHPを使用してraw XMLを出力する]の可能な複製(http://stackoverflow.com/questions/7139708/output-raw-xml-using-php) – fusion3k

答えて

0

sitemap_index.phpファイルを含める**最初に**この

<?php 
    header("Content-Type: application/xml; charset=UTF-8"); 
    echo "<?xml version='1.0' encoding='UTF-8'?>"; 
    $sql = "SELECT ceil(count(*)/5000) as total FROM `produto_price`"; 
    $result = mysql_query($sql); 
    $row = mysql_fetch_array($result); 
?> 
<sitemapindex 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/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
    <sitemap> 
     <loc>http://omenorpreco.com/sitemap-categoria.xml</loc> 
     <lastmod><?php echo date('Y-m-d'); ?></lastmod> 
    </sitemap> 
<?php for($i = 1; $i <= $row['total']; $i++): ?> 
    <sitemap> 
     <loc>http://omenorpreco.com/sitemap-<?php echo $i ; ?>.xml</loc> 
     <lastmod><?php echo date('Y-m-d'); ?></lastmod> 
    </sitemap> 
<?php endfor; ?> 
</sitemapindex> 
+0

ありがとうございます!私はこの問題を何日も解決しようとしました! –

関連する問題