如何configurationhttpd.conf,使得<perl> </ perl>中的脚本只有在查询string中有标志参数的情况下才能运行?

mod_perl提供了一种在httpd.conf运行perl脚本的方法:

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

如何configurationhttpd.conf使得<perl></perl>中的脚本只有在查询string中有flag参数的情况下才能运行?

使用Perl来评估query_string,然后if未设置参数,则使用if语句跳过其余部分。

也许这样的*:

 <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> 

*可能有其他方法来分解query_string, 这里是我的例子 。