htaccess and redirect

how to get htaccess working and redirect feed to feedburner

2012-01-12

Okay, so after my post about htaccess the other day, I still had one more thing to do before I could get the rewrite rules working.

I wanted to redirect requests for my podcast rss feed (eg any reqests for the specific feed.xml file) to feedburner, but whenever I put the rewrite rules into my .htaccess file I would keep seeing an “internal server error”.

I made the following changes to get it working. This is for ubuntu, but should work for any apache unix install.

First, I surronded the rewrite rules with <IfModule mod_rewrite.c> flags, which stopped the “internal server error” showing to any request no matter the url.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT}  !FeedBurner
RewriteRule ^feed\.xml$        http://feeds.feedburner.com/themarshcast [R=301,L]
</IfModule>

This meant the marsh cast site would work again, but requests for feed.xml still wern’t being redirected.

I then found on Mehdi Behamins blog[dead link] that I had to enable the apache module rewrite by runing

sudo a2enmod rewrite

and restarting apache with

sudo service apache2 restart

Now requests for feed.xml go to the feedburner feed url.