Since this is a mod_perl list, I'll suggets a Perl solution. Write a
PerlTransHandler that does what mod_rewrite does. You can get the query string
from $r->args and send redirect headers.
A quick example (this works, BTW):
package Apache::Redirect::Based::On::Query::String;
use Apache::Constants 'OK','REDIRECT';
use constant DEFAULT_URI => 'http://www.boston.com'; # shameless plug!
sub handler {
my $r = shift;
my %args = $r->args;
my $path = $r->uri;
# $uri holds something like 'http://www.mysite.com/news/' if the initial
# request was 'http://www.yoursite.com/news/?uri=http://www.mysite.com/'
my $uri = (($args{'uri'}) ? $args{'uri'} : DEFAULT_URI) . $path;
$r->header_out->add('Location' => $uri);
$r->status(REDIRECT);
$r->send_http_header;
return OK;
}
Set it up in httpd.conf as:
PerlTransHandler Apache::Redirect::Based::On::Query::String
darren
Jason Simms ([EMAIL PROTECTED]) wrote:
> I am having a little trouble with mod_rewrite (probably because I think I am
> using it for something it was not intended to do). Basically what I want to
> accomplish is to redirect the user based on several rules. The problem is,
> the rules are based on both the logical path _and_ the query string. I have
> successfully redirected using tests on the path (i.e.,
> http://www.mysite.com/MY/PATH), but mod_rewrite does not seem to allow me to
> test the query string.
>
> I know that by using RewriteCond I can use environment variables, inclduing
> QUERY_STRING, as conditions for my test. But, when it comes to the actual
> redirection, RewriteRule does not seem to let me run a regex on the query
> string (i.e., it is stripped off and held).
>
> The problem with this is that the url that I want to redirect the user to is
> going to be coming to me from within the query string. So, if I have a
> query string as such:
>
> http://www.mysite.com/redirect?uri=http://www.othersite.com
>
> I want to test if the path is redirect (easy to do), but then for the
> substitution I want to use the value in the uri parameter.
>
> I know I can reappend the string using the flag QSA, but I can't seem to
> extract values from this string to use in the redirect. I also know I can
> simply write a perl module to handle this, but I wanted the speed increase I
> can get from C (which is, of course, what mod_rewrite is written in). Any
> suggestions?
>
> Jason Simms
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
--
Jesus saves, passes to Moses; shoots, SCORES!