How to add a .xml extension to a specific URI using .htaccess

帅比萌擦擦* 提交于 2019-12-11 04:24:01

问题


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.



来源:https://stackoverflow.com/questions/11545470/how-to-add-a-xml-extension-to-a-specific-uri-using-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!