0

I created a rss feed for my site and the url looks like this: http://abcde.com/rss/rss.php

I want an url like this: http://abcde.com/rss/rss.xml

How to do this, please help me.

Thanks in advance.

Karthik
  • 2,519
  • 4
  • 24
  • 29

2 Answers2

2

.htaccess rules?

If you want all .xml files to point to php files, use these.

RewriteEngine On
RewriteBase   /rss

RewriteRule  ^(.*).xml$ $1.php [R=301]

This should also work:

RedirectMatch perm ^/rss/(.+)\.xml$ http://yoursite.com/rss/$1.php

Otherwise, use the code Jason McCreary suggested:

RewriteEngine On
RewriteBase   /rss

RewriteRule  ^rss.xml$ rss.php [L]

Which will only rewrite rss.xml to rss.php.

Code Magician
  • 23,217
  • 7
  • 60
  • 77
  • I'm assuming apache, I don't know the solution on other web servers. Apparently this is the solution on IIS http://stackoverflow.com/questions/60857/mod-rewrite-equivalent-for-iis-7-0 – Code Magician Aug 18 '11 at 17:24
  • 2
    This is a bit aggressive. It's better to be specific, i.e. `^rss.xml$ rss.php [L]` Otherwise, all `.xml` requests will be redirected to `.php` – Jason McCreary Aug 18 '11 at 17:25
  • Great point @Jason. When I did something similar, that was the desired behavior but I didn't consider the alternative. – Code Magician Aug 18 '11 at 17:37
1

I recommend to generate a static xml file via php and give access to this file.

Invoking php script that reads back-end database every time to generate rss feed, especially when there are many users, may affect on your server performance.

Generate a static xml file and update it every time when you update your web-site.

And provide link to this static xml file.