Hi, i want to ask about my RSS script that generated by my php code. the problem is when user klick the link, it generates the file as .php not .XML. But the content is ok. here is the script: <?php include "conConfig/config.php"; $connection=mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($db,$connection); $query = "select title, author, text from `news` limit 15"; $result = mysql_query($query, $connection); while ($line = mysql_fetch_assoc($result)) { $return[] = $line; } $now = date("D, d M Y H:i:s T"); $output = "<?xml version=\"1.0\"?> <rss version=\"2.0\"> <channel> <title>News Title</title> <author>Author</author> <description>Description</description> <language>en-us</language> <pubDate>$now</pubDate> <lastBuildDate>$now</lastBuildDate> <docs>http://www.testBaelah.com</docs> <managingEditor>sigokil@testBaelah.com</managingEditor> <webMaster>web@testBaelah.com</webMaster> "; foreach ($return as $line) { $output .= "<item> <title>".htmlentities($line['title'])."</title> <author>".htmlentities($line['author'])."</author> <description>".htmlentities(strip_tags($line['text']))."</description> </item>"; } $output .= "</channel></rss>"; header("Content-Type: application/rss+xml"); echo $output; ?> PHP: And this is the content of the result file if the link is clicked by visitor. RSS.php <?xml version="1.0"?> <rss version="2.0"> <channel> <title>News Title</title> <author>Author</author> <description>Description</description> <language>en-us</language> <pubDate>Sun, 30 Dec 2007 10:05:32 SE Asia Standard Time</pubDate> <lastBuildDate>Sun, 30 Dec 2007 10:05:32 SE Asia Standard Time</lastBuildDate> <docs>http://www.testBaelah.com</docs> <managingEditor>sigokil@testBaelah.com</managingEditor> <webMaster>web@testBaelah.com</webMaster> <item> <title>News this week</title> <author>Jack</author> <description>This the content</description> </item> <item> <title>News this week 2</title> <author>Darsimin</author> <description>This the content 2</description> </item> </channel> </rss> PHP: My problem is, i want to make it generated as rss.xml not as rss.php, so it can be opened directly by web browser. I hope some one can help & solve my problem. Best Regards Sandy Junandya
The browser looks for the content-type and renders accordingly, so you script can be anything you call it. You should perhaps change the MIME-type to text/xml or application/xml for all browsers to recognize it as a feed.
Put this after the include line: header('Content-Type: text/xml'); PHP: and use the Kaizoku's .htaccess suggestion too, to be able to call it as rss.xml
There is no need to change the extension. If the headers that are sent are XML, it will be viewed as XML by all browsers/feeders. Peace,