# MIME Types, PHP, and XML

**URL:** <https://boards.straightdope.com/t/mime-types-php-and-xml/381352>\
**Category:** Factual Questions\
**Created:** [November 21, 2006, 10:36pm UTC](https://boards.straightdope.com/t/mime-types-php-and-xml/381352 "2006-11-21T22:36:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)\
**Post date:** [November 21, 2006, 10:36pm UTC](https://boards.straightdope.com/t/mime-types-php-and-xml/381352/1 "2006-11-21T22:36:34Z")

</div>

I have a PHP file that dynamically creates an RSS/XML feed. It worls fine, but some readers want to see a “.xml” extension on the feed file rather than a “.php” extension.

What is the reight way to set up the .htaccess file so that the .xml file is run through the PHP interpreter but is still output with a MIME type of XML.

I know that I could use header redirection, but that doesn’t work in my app for another reason too long to explain.

---

<div class="post-metadata">

**Author:** ![Caught\_Work](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@Caught\_Work](https://boards.straightdope.com/u/Caught_Work)\
**Post date:** [November 21, 2006, 11:40pm UTC](https://boards.straightdope.com/t/mime-types-php-and-xml/381352/2 "2006-11-21T23:40:14Z")

</div>

Try this:

RemoveHandler .xml  
AddType application/x-httpd-php .xml

That should add the xml extension to run through the interpreter.  
Not tested: Use at your own risk.

---

<div class="post-metadata">

**Author:** ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)\
**Post date:** [November 22, 2006, 12:06am UTC](https://boards.straightdope.com/t/mime-types-php-and-xml/381352/3 "2006-11-22T00:06:53Z")

</div>

[QUOTE=Caught@Work]  
Try this:

RemoveHandler .xml  
AddType application/x-httpd-php .xml

That should add the xml extension to run through the interpreter.  
Not tested: Use at your own risk.  
[/QUOTE]

Thanks, that seems to work! Can you explain what those magic lines did?
