Re: Using mod_rewrite to modify Query String
"Jim Hayter" <see.reply.to@nowhere.invalid> schreef in bericht
news:13i1kffdhhmfm06@news.supernews.com...
> Laura wrote:
> <snip>
>> by the way: since there can be more parameters with "null" in the
>> query string, do you think that would work the same ?
>
> You might consider using the RewriteMap directive to send your
> Query_string to a script to parse and rewrite. You could then use the
> result as either an internal or external redirect.
>
> Example (untested):
> RewriteMap fix_query_string prg:<location of program>
> RewriteCond %{QueryString} "=null"
> RewriteCond %{QueryString} ^(.+)$
> RewriteRule ^(.*)$ $1?${fix_query_string:%1|%1}
>
> The first condition tests for the "=null" string, the second puts the
> query string in %1. The rewrite rule captures the request_uri in $1 and
> rewrites it to itself with the result of passing the query string to the
> script. If the script returns the special value "NULL", it uses the final
> %1 (after the |) instead of the script output. You will probably need to
> consult a good source on how to write the script. It is started when
> Apache starts and reads from stdin and writes to stdout.
>
Maps do not only eat backticks:
RewriteMap fix_query_string prg:<location of program>
RewriteCond %{QueryString} "=null"
RewriteRule ^(.*)$
$1?${fix_query_string:%{QueryString}|%{QueryString }}
HansH
|