Changing content-type for a single php file
Posted: Fri Jan 07, 2011 12:47 pm
I was having a problem with a dynamic rss feed I made in php. Everything works with the feed readers I tested it in but when I try to validate it at w3c I get "Feeds should not be served with the "text/html" media type." It says that the mime type should be application/rss+xml or something similar, and that this is only for maximum compatability. I would like my feed to be fully compatibile. When I declare the content-type with the header function in php, it says that the server that my website is hosted on has already sent the content-type header (text/html). My web hoster said I can change the default_mimetype setting in php.ini. My dynamic rss feed has a .php extension. The problem is that I want all the .php files to be served as text/html, but I want this specific file (the rss feed) to be served as application/rss+xml. Is there a way to do this? If I change my extension of my dynamic rss feed to .xml the PHP processor doesn't process the script in the file. I might be able to change the server settings to send .xml files to the PHP processor, but I would prefer it if I could just change the php.ini file so that I can keep everything the same, but just have my rss feed sent as an application/rss+xml document.
Martin
Martin