[mod_python] Getting query parameters when there is RewriteRule

sliderw hotmail sliderw at hotmail.com
Thu Apr 26 14:40:40 EDT 2007

Doing qp = req.args works (for both cases). I didn't know about req.args. 
Thanks for the suggestion.

>From: "Graham Dumpleton" <graham.dumpleton at gmail.com>
>To: "sliderw hotmail" <sliderw at hotmail.com>
>CC: mod_python at modpython.org
>Subject: Re: [mod_python] Getting query parameters when there is 
>Date: Thu, 26 Apr 2007 13:05:00 +1000
>On 26/04/07, sliderw hotmail <sliderw at hotmail.com> wrote:
>>In httpd.conf, I have:
>>RewriteRule ^/dl/([^/\?]+)/([^/\?]+)/? /dl/myhandler.py?a=$1&b=$2 [PT,L]
>>Alias /dl/ "/some/path/"
>><Directory "/some/path/">
>>   ... mod_python stuff here for myhandler ...
>>myhandler gets the query parameters using qp =
>>req.parsed_uri[apache.URI_QUERY]. If I go to
>>http://www.mysite.com/dl/myhandler.py?a=1&b=2, qp is "a=1&b=2", as 
>>On the other hand, if I go to http://www.mysite.com/dl/1/2/, qp is None, 
>>I expect qp is "a=1&b=2". How can I make this work?
>Have you enabled debug in mod_rewrite and looked at the rewrite log to
>verify what that your rule matches and is getting rewritten to what
>you expect it to? What does it show?
>What is the 'mod_python stuff here for myhandler' which you are using?
>Have you tried using 'req.args' instead of getting it out of 
>There is possibly a better way of doing this which avoids mod_rewrite
>altogether but will have to think about it first before I suggest some
>code to actually try. In short though it involves using a fixuphandler
>to trigger mod_python instead of the Apache configuration. One can be
>explicit about handler you then want executed and pass what you are
>passing through as args as attributes stored against the request
>object. Avoids having to do form args processing in actual response

Interest Rates NEAR 39yr LOWS!  $430,000 Mortgage for $1,299/mo - Calculate 
new payment 

More information about the Mod_python mailing list