httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thias <>
Subject [users@httpd] RewriteMap script puts newline character in URL
Date Wed, 17 Dec 2003 21:22:14 GMT

I'm trying to use a RewriteMap and a RewriteRule for load balancing. I use a
python script in the RewriteMap to modify the URL but I get a newline
character in the URL which causes a browser error.

HTTP ERROR: 404 /ctms/%0D Not Found 

My environment is as follows: 
 1. Apache 2.0.48
 2. Win2K 5.00.2195 Service Pack 3
 3. Python23

My httpd.conf looks as follows:

RewriteEngine on
RewriteLogLevel 20
RewriteLog rewrite.log
RewriteMap servers "prg:C:/Tools/Python23/python.exe c:/"
RewriteRule ^/ctms/(.*) ${servers:$1}  [P,L]

My python script:



import sys
import string
import os

if __name__ == "__main__":
    servers = ['http://server1:8080/ctms/','http://server2:8080/ctms/']
    while 1:
        data = sys.stdin.readline()
        if not data:
        count = (count+1) % 2
        print servers[count]  ( remaps correctly but puts newline character
in URL )
#        sys.stdout.write("%s" % servers[count])  (tried this but causes
#        sys.stdout.write("%s\n" % servers[count])  (tried this, same as
        sys.stdout.flush()  ( if I don't have this, does not remap )


(2) init rewrite engine with requested uri /ctms/
(3) applying pattern '^/ctms/(.*)' to uri '/ctms/'
(2) init rewrite engine with requested uri /ctms/
(3) applying pattern '^/ctms/(.*)' to uri '/ctms/'
(5) map lookup OK: map=servers key= -> val=http://server1:8080/ctms/ - - [17/Dec/2003:15:12:20 --0600]
[server1/sid#23c590][rid#47e9c0/initial] (2) rewrite /ctms/ ->
http://server1:8080/ctms/ - - [17/Dec/2003:15:12:20 --0600]
[server1/sid#23c590][rid#47e9c0/initial] (2) forcing proxy-throughput with
http://server1:8080/ctms/ - - [17/Dec/2003:15:12:20 --0600]
[server1/sid#23c590][rid#47e9c0/initial] (1) go-ahead with proxy request
proxy:http://server1:8080/ctms/<newline character here> [OK]

Thank you for any leads you may have to this problem.

Mark Thias

This email may contain confidential and privileged material for the sole use
of the intended recipient. Any review or distribution by others is strictly
prohibited.  If you are not the intended recipient please contact the sender
and delete all copies.

View raw message