Jump to content

[SOLVED] Treating .xml file as PHP (.htaccess not working?)


neo926

Recommended Posts

I have an RSS feed for my site that pulls data from my MySQL database, so since it's an XML file and uses PHP in it, I have added

AddType application/x-httpd-php .xml

So that the XML file displays properly.  Well, that's been working fine until about a month ago.  Our server crashed and our web host had to rebuild it.  Well, when they rebuilt it, the XML file no longer displays properly.  We actually just moved to a new webhost, but I still seem to be having the same problems.  Basically the PHP code in the file isn't being parsed at all.  For example:

 

http://secondcitysaint.com.s60090.gridserver.com/rss2.php

 

Here's the code with a .php extension.  Works fine.

 

http://secondcitysaint.com.s60090.gridserver.com/rss2.xml

 

But when I change it to a .xml extension, it doesn't work at all.  My .htaccess file is correct as far as I know, and as I've said, it used to work, for years, I didn't change anything, but clearly something got screwed up somewhere, and I don't have a clue what it could be.

 

I know that ultimately I could just change my RSS feed to point to the .php extension, but all of my readers already subscribe to the .xml file, so I'd rather not do that if at all possible.  Any help would be appreciated.

did you have a look at the source of the link

<? header('Content-type: text/xml'); ?>

<rss version="2.0">
<channel>
<title>SecondCitySaint.com</title>
<description>It's About Me</description>
<link>http://secondcitysaint.com/</link>
<copyright>All material copyright 2004-2009 Mike Maloney</copyright>


     <item> 
        <title>

<![CDATA[

<?php echo "Hi."; ?>

]]>

</title>

<description>

<![CDATA[

<?php echo "Hello again"; ?>

]]>

</description>

        <link>http://secondcitysaint.com/index.php?id=<?php echo "243"; ?></link> 
     </item>    

</channel>
</rss>

your server doesn't have short tags enabled (<?)

try adding <?php to the start

or updating you php.ini to allow short tags

 

Scott.

 

 

sorry silly me didn't see that

umm try adding

AddHandler php5-script .xml

and dont use the AddType directive

to your htaccess file also you should be able to find all the info you need in

/etc/httpd/conf.d/php.conf on linux im not sure of the windows path

 

Scott.

That did the trick!  That's fantastic, thank you very much!

 

On a side note, would my problem have anything to do with whether my site is running php4 or php5?  Right now it's running php4, but I believe I have the option to change to php5.

 

Again, thanks a lot.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.