Forum Moderators: phranque

Message Too Old, No Replies

User agent redirect

with mod_rewrite

         

wesg

5:54 pm on Aug 10, 2008 (gmt 0)

10+ Year Member



I know the issue has been hashed to pieces, but a search through the forums did not yield an answer.

All I want to do is redirect all users who access my RSS feed with a browser, but leave the FeedBurner bot alone -- otherwise there are too many redirects.

This is what I have so far:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
rewriteCond %{REQUEST_URI} /rss.php
RewriteCond %{HTTP_USER_AGENT} !^FeedBurner
RewriteRule .* [feeds.feedburner.com...] [R=301,L]
</IfModule>

This htaccess file is in the same folder as the file rss.php and yet I have nothing. Any help?

jdMorgan

6:11 pm on Aug 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need <IfModule> -- Either mod_rewrite is installed or it isn't. If it isn't, it would be better to get an error message, which <IfModule> will prevent.

Cleaning up what's left gives:


Options +FollowSymlinks
RewriteEngine on
#
RewriteCond %{HTTP_USER_AGENT} !^FeedBurner
RewriteRule ^rss\.php$ http://feeds.feedburner.com/feed [R=301,L]

This presumes that the feedburner user-agent string starts with exactly "FeedBurner" -- All letters and uppercase/lowercase matching, and that the request is for the exact URL "rss.php" (ignoring any query strings appended to that URL).

Flush your browser cache completely when changing the code or when switching between your browser user-agent and the FeedBurner user-agent strings while testing.

Jim

wesg

6:26 pm on Aug 10, 2008 (gmt 0)

10+ Year Member



Thanks jD, that did the job!