• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

.htaccess Questions -- Redirect if a Certain Variable Is Passed

orty

Golden Member
I'm not a RegEx expert, and maybe it's because I haven't had my coffee today, but I just can't wrap my head around this right now.

I have a gregarius install that gets a bunch of traffic locally (it's a local blog aggregator) that I'm going to be converting in the near future to use a different back-end. Since I get a bunch of traffic to the site's RSS/Atom feed, I don't want to lose that, and I'd rather them be using my Feedburner-based feed anyway (saving my server some load). So I'd basically like to redirect all URLs that have "?media=atom" or "?media=rss" in the URL (all other "?media=xxx" need to be left alone) to the following URL: http://feeds.bendblogs.com/bendblogs . I'd like to make it a 301 as that way I can then use that URL when I re-do the backend sometime or anytime, folks will still be using the right feed address.

Thoughts?
=Jake
 
No dice -- doesn't appear to be triggering the redirect (go to http://bendblogs.com/?media=rss or http://www.bendblogs.com/index.php?media=atom ), and it might have to do with the other stuff in my .htaccess file (which is all provided with gregarius):
Code:
Options -MultiViews
AddDefaultCharset utf-8

RewriteEngine on

# Redirecting Feeds to Feedburner
Options +FollowSymlinks 
RewriteRule ^.+\?media=[atom|rss].*$ [url="http://feeds.bendblogs.com/bendblogs"]http://feeds.bendblogs.com/bendblogs[/url] [R=301,NC] 





  # If we have a file or a directory match then lets set the 
  # static variable
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^.*$ - [E=static:1]
  
  SetEnvIf Request_URI "/css/" static
  SetEnvIf Request_URI "/img/" static
  SetEnvIf Request_URI "/admin/" static
  SetEnvIf Request_URI "/extlib/" static
  SetEnvIf Request_URI "/test/" static
  SetEnvIf Request_URI "/themes/" static
  SetEnvIf Request_URI "/plugins/" static
  # You can add other lines here to have static content 
  # under a gregarius installation.
  
  #admin section
  RewriteRule   ^admin/sub/(.+)$ admin/index.php?domain=feeds&add_channel_to_folder=0&action=Add&new_channel=$1 [L,NE]
  RewriteRule 	^admin/([a-z]+)$	admin/index.php?view=$1 [L]
  
  #opml
  RewriteRule 	^opml.*$		opml.php?act=export [L]

  #tag view
  RewriteRule	^tags?/?$			tags.php?alltags [L,QSA]
  RewriteRule	^tag/(.+)$  	tags.php?tag=$1 [L,QSA]
  RewriteRule	^tag/(.+)/rss/?$  tags.php?tag=$1&rss [L,QSA]
  
  #state view
  RewriteRule ^state/(.+)/?$ state.php?state=$1 [L,QSA]

  #author view
  RewriteRule ^author/(.+)$ author.php?author=$1 [L,QSA]

  #date view
  RewriteCond  %{env:static} ^$
  RewriteRule ^(20[0-1][0-9])/([0-9][0-9]?)/([0-9]?[0-9])/?$ feed.php?y=$1&m=$2&d=$3 [L,QSA]

  #item view
  RewriteCond  %{env:static} ^$
  RewriteRule  ^(.+)/(20[0-1][0-9])/([0-9][0-9]?)/?([0-9]?[0-9])?/?(.*)?$ feed.php?channel=$1&y=$2&m=$3&d=$4&iid=$5 [L,QSA]
  
  #feed view
  RewriteCond  %{env:static} ^$
  RewriteRule ^(.+)/(.*)?$   feed.php?channel=$1&iid=$2 [L,QSA]

  #feed view - without the trailing slash
  RewriteCond  %{env:static} ^$
  RewriteRule ^(.+)/?$   feed.php?channel=$1 [L,QSA]

### php_value xdebug.profiler_enable 1

While I did find a PHP way to work around this (editing the RSS/Atom files and checking for http headers in those files and then redirecting), I'd still like to know if there's a way to do this in .htaccess. Ideas?
 
Back
Top