-->

How to add a .xml extension to a specific URI usin

2019-07-24 05:19发布

问题:

I have a URL at the moment www.mydomain.com/feed/my_feed/ which writes out an xml document to be read by a third party. The XML document is dynamically generated (I'm using ExpressionEngine).

The third party have requested that it must have a .xml extension to be read.

Any ideas how I could set up a .htaccess rule to only use a .xml file extension for this particular uri?

Most tutorials are concerned with removing file extensions adding file extensions to all urls, which doesn't help a .htaccess noob.

Many thanks in advance.

回答1:

So if the URL the third party is using is: www.mydomain.com/feed/my_feed.xml

You want to add this in the htaccess file in your document root:

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


回答2:

I've had trouble using .htaccess to rewrite the .xml off of a URL before. Frequently when I need to do this I'll just use the Pages module and put /something/something.xml as the Pages URI. Then you can point the page at any template you want.