ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Appending a .xml file extension to the end of an EE generated XML document

July 20, 2012 12:34pm

Subscribe [1]
  • #1 / Jul 20, 2012 12:34pm

    Rob Games

    38 posts

    I have created an XML feed in EE, using a template (type set to XML) and channel entries tag to parse all the data.

    For whatever reason the company that is receiving the feed (they are reading the XML document via HTTP) require it to have a .xml file extension appended to the end.

    I thought this should be quite a simple one using .htaccess, however the page does not get parsed when I do this.

    For simplicity take the following example:

    Current URL (all working): http://www.mydomain.com/feed/my_feed/
    Desired URL: http://www.mydomain.com/feed/my_feed.xml

    I thought the answer would be something along the lines of a .htaccess statement similar to this:

    RewriteEngine On
    RewriteRule ^/?feed/my_feed.xml$ /feed/my_feed/ [L]

    However, this just returns a blank screen (nothing has been parsed).

    Again for simplicity my template looks like this:

    <?xml version="1.0"?>
    
    <!DOCTYPE product_catalog_data SYSTEM "http://www.xyz.com/product_catalog_data_1_1.dtd">
    
    
    
         {exp:channel:entries channel="product" disable="pagination|member_data|category_fields" dynamic="no"}
    
         
    
              <name>{title}</name>
              <otherdetail>{custom_field}</otherdetail>
    
         </product>
    
         {/exp:channel:entries}
    
    

    If anyone has any bright ideas they fancy sharing it would be most appreciated.

    In case any one has any prior experience, this is for an affiliate product feed for Commission junction.

    Many thanks in Advance.

  • #2 / Jul 20, 2012 1:52pm

    It’s not working because Apache’s going to try to process that request with /feed/my_feed/, which is the path to an EE template, and not a file on the server. I suspect you need something like this, which includes index.php:

    RewriteEngine On
    RewriteRule ^/?feed/my_feed.xml$ /index.php?/feed/my_feed/ [L]
  • #3 / Jul 23, 2012 4:51am

    Rob Games

    38 posts

    Thanks Nick, that makes sense.

    Another really simple way around this without any additional code would be to add an additional segment with a file extension to the end, e.g:

    Actual URL: http://www.mydomain.com/feed/my_feed/
    Desired URL: http://www.mydomain.com/feed/my_feed/any_name_you_want.xml

    In this case, it would default to reading ‘my_feed’.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases