Send sitemap.php (not XML) to Google

0

I do not know if the process of sending the system in PHP format varies somewhat with respect to XML. I've uploaded it to Google but I get an error:

  

Your sitemap seems to be an HTML page. a compatible sitemap format.

I have not found too much information for these cases. What I have done is generate the sitemap with PHP, I save it as sitemap.php in the root of the project, and upload it via FTP.

In htaccess I have included the following code:

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

And in robots.txt the following:

Sitemap: http://miweb.com/sitemap.xml 

In miweb.com I have the domain of my web.

Am I doing something wrong?

The only question I have is that in the robots.txt file I have an error:

User-agent: Twitterbot
Disallow: * //aquí el error

But it's another question I want to ask in another post.

I edit to add the code I have in the sitemap:

<?php

header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'
        xmlns:news='http://www.google.com/schemas/sitemap-news/0.9'>";

    require 'admin/config.php';
    require 'funciones.php';

    try {
        $conexion = new PDO($bd_config['dbname'], $bd_config['usuario'], $bd_config['password'] );
    } catch (PDOException $e) {
        header ('Location: error.php');
        echo "ERROR: ".$e->getMessage();
        die();
    }

    //código

echo "</urlset>\n";

?>
    
asked by JetLagFox 16.06.2017 в 21:17
source

0 answers