You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Covington, Chris" <Ch...@plusone.com> on 2005/09/29 22:15:01 UTC

[users@httpd] % mod_proxy URL issue

Is it possible to have a mod_rewrite rule which will rewrite a % with a
%25?  Below is a hack for Outlook Web Access which, when
reverse-proxied, apache2 chokes on when a % is in a subject of an email
(and thus in the URL) unless the following is done.

Chris

Insert this right before your "front-end" Proxy* directives in
httpd.conf.
# Using mod_rewrite to fix a problem when percent symbols are in
# the subject line of the OWA email (the email subject is used
# in the web query - WTF?). The entire URI is passed to a small
# bash script I wrote that replaces all occurrences of the % symbol
# with the URI escape sequence (%25). That seems to make everything
# happy.
RewriteEngine On
RewriteMap damnpercent prg:/usr/local/bin/percent_rewrite
RewriteCond $1 ^/exchange/.*\%.*$
RewriteRule (/exchange/.*) ${damnpercent:$1} [P]

The simple bash script uses sed to work its magic. You'll notice I am
also sending the original and changed URL to a log file in /tmp. This
helps with troubleshooting and can be shut off when you're confidant
everything is working. (This could easily be rewritten in any language.)
#!/bin/bash

LOGFILE=/tmp/percent_rewrite.log
cat /dev/null > $LOGFILE

while read URL
do
NEWURL=$(echo "$URL" | sed -e "s/%/%25/g")
echo "Changing $URL to $NEWURL" >> $LOGFILE
echo $NEWURL

done

---
Chris Covington
IT
Plus One Health Management
75 Maiden Lane Suite 801
NY, NY 10038
646-312-6269
http://www.plusoneactive.com


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org