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.

1
  • What web server are you using? Most people use a rewrite rule in Apache Commented Aug 18, 2011 at 17:21

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm assuming apache, I don't know the solution on other web servers. Apparently this is the solution on IIS stackoverflow.com/questions/60857/…
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
Great point @Jason. When I did something similar, that was the desired behavior but I didn't consider the alternative.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.