2

mod_perl provides a way to run perl scripts in httpd.conf:

<perl>
...scripts goes here...
</perl>

How do I configure httpd.conf so that scripts inside <perl></perl> only get run if there's a flag parameter in the querystring?

linux
  • 1,143
  • 3
  • 12
  • 15

1 Answers1

1

Use Perl to evaluate the query_string and then use an if statement to skip the rest if the parameter is not set.

Perhaps something like this*:

<perl>
     if (length ($ENV{'QUERY_STRING'}) > 0){
           $buffer = $ENV{'QUERY_STRING'};
           @pairs = split(/&/, $buffer);
           foreach $pair (@pairs){
                ($name, $value) = split(/=/, $pair);
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
                $in{$name} = $value; 
           }
     }
     if (defined $in{'flag'}){
          #Your Code here
     }
</perl>

*there might be other ways to break up the query_string, here's where I got my example.

matthew
  • 1,309
  • 1
  • 11
  • 21