Forum Moderators: phranque

Message Too Old, No Replies

Double RewriteRule redirection with query

how to deal with the question mark

         

eSite

6:43 pm on Aug 28, 2006 (gmt 0)



Hi,

I have a bilingual blog with a feed for each language.
I would like to redirect each feed to a feedbmurner URI but I don't know how to deal with the question mark nor how to have all rules working together.

 
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT}!FeedBurner
RewriteRule ^index\.php/bilingual/feed/?lang=en$ http://feeds.feedburner.com/myblog-en [R=302,L]
RewriteRule ^index\.php/bilingual/feed/?lang=fr$ http://feeds.feedburner.com/myblog-fr [R=302,L]

jdMorgan

7:55 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I would like to redirect each feed to a feedbmurner URI but I don't know how to deal with the question mark

What do you want to do with the question mark? It delimits the query string from the URL. Do you want/need to pass the query string to the feedburner URL? I doubt it, but I don't know anything about your project...

> nor how to have all rules working together.

How do they or do they not work together now? How have you tested? What were the results? How did those results differ from your expectations?

Why are you testing the User-agent to see if it's not Feedburner?

Are you aware that a RewriteCond only applies to the single RewriteRule that follows it? This means that you may need to duplicate the RewriteCond or structure your code differently if both rules need to be qualified by the requesting User-agent.

Jim

eSite

10:13 pm on Aug 28, 2006 (gmt 0)



> What do you want to do with the question mark?
This is how I display content in the specified language - on my site.

> Do you want/need to pass the query string to the feedburner URL?
No need, it's just that the question mark is breaking the rule.

> Why are you testing the User-agent to see if it's not Feedburner?
Because I want to use Feedburner while keeping people subscribed to my own URI.

> Are you aware that a RewriteCond only applies to the single RewriteRule that follows it?
No that is what I meant by working together, I just want the code to be as compact as possible.

[edited by: eSite at 10:15 pm (utc) on Aug. 28, 2006]

jdMorgan

3:28 am on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Single rule for en and fr cases:

RewriteEngine on
#
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteCond %{QUERY_STRING} ^lang=(en¦fr)$
RewriteRule ^index\.php/bilingual/feed/$ http://feeds.feedburner.com/myblog-%1? [R=302,L]

The %1 in the substitution URL refers to the matched contents of the parenthesized pattern in the last RewriteCond.

Replace the broken pipe "¦" character above with a solid pipe character before use; Posting on this board modifies that character.

Jim

eSite

8:03 am on Aug 29, 2006 (gmt 0)



Perfect, I like help from efficient people like you, thanks a lot.