cant generate sitemap1.xml in root directory

Discussion in 'Apache' started by darkc99, May 30, 2011.

  1. #1
    hello
    i have little php code which cant generate sitemap1.xml in root directory , actually i reinstalled the os on my vps but on my old installation the same code was working and was able to generate sitemap1.xml in root but now its not working it does not give any error ...........

    function write_xml($url,$priority = 0.7)
        {
        global $handle, $counter, $file_number, $filename;
    
       if($counter >= 50000)
            {
            $file_number++;
            $counter = 0;
            // Attach end of file, and close it here.
            fwrite($handle,"</urlset>\n");
            fclose($handle);
            }
    
        if($counter == 0)
            {
           // Open next file here.
            $filename = "sitemap" . $file_number . ".xml";
            $handle = fopen($filename,"a");
            fwrite($handle,'<?xml version="1.0" encoding="UTF-8"?>' . "\n");
            fwrite($handle,'<urlset xmlns="http://www.google.com/schemas/sitemap/0.9">' . "\n");
            }
        if($url != "" && $url != "END")
            {
            fwrite($handle,"\t <url>\n");
            fwrite($handle,"\t\t<loc>$url</loc>\n");
            fwrite($handle,"\t\t<priority>$priority</priority>\n");
            fwrite($handle,"\t</url>\n");
            }
        if($url == "")
            {
            fwrite($handle,"</urlset>\n");
            fclose($handle);
            }
    // Increment counter for every URL.
        $counter++;
        }
    Code (markup):
    please help
     
    darkc99, May 30, 2011 IP
  2. stardust.x7

    stardust.x7 Active Member

    Messages:
    369
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    90
    #2
    Did you set dir permission being writable correctly?
     
    stardust.x7, Jun 3, 2011 IP