On 11/10/06, DM <[EMAIL PROTECTED]> wrote:
Hi,
Thanks for the advice about QUERY_STRING. Please allow me to re-state my
problem and my current attempt at a solution:
I want to rewrite a URL such as:
http://www.example.org/myProgram?param1=val1&url=http://cellularlmanagerpp.aliant.net/foo/bar.html
to
http://www.example.org/myProgram?param1=val1&url=http://erie:9090/foo/bar.html
Currently, I'm using the following RewriteRule:
RewriteCond %{QUERY_STRING}
^(.*)url=http%3A%2F%2Fcellularmanagerpp%2Ealiant%2Enet(.*)$
RewriteRule ^(.*)$ %3?%1url=http%3A%2F%2Ferie%3A9090%2
My intention is this
- the first pattern captured (%1) in RewriteCond will be everything from the start of the
query string up to "url"
- the second pattern captured (%2) in RewriteCond will be everything in the query string
after "aliant.net"
- the third pattern captured (%3) in RewriteRule will be everything from the
beginning of the URL to the start of the query string
Therefore "%3?%1url=http%3A%2F%2Ferie%3A9090%2" should produce the URL I want,
but unfortunately it doesn't
Once potential problem I can see is that there is no distinction between the use of "%3" to replay the third
captured pattern and the use of "%3" in "%3A", to represent the ":" character encoded -
should I somehow be escaping the latter?
Much better problem description.
Your primary problem is that you don't know the difference between the
two types of back-references in mod_rewrite. %1, %2, etc do
back-references to RewriteConds, while $1, $2, etc are for
RewriteRules. So you want something more like:
RewriteCond %{QUERY_STRING}
^(.*)url=http%3A%2F%2Fcellularmanagerpp%2Ealiant%2Enet(.*)$
RewriteRule ^(.*)$ $1?%1url=http\%3A\%2F\%2Ferie\%3A9090\%2
Last piece of advice: You should use the RewriteLog to debug this type
of problem. It will show you clearly what mod_rewrite is doing. I'm
not sure of the exact escaping rules, but you should be able to figure
them out using the RewriteLog.
Joshua.
---------------------------------------------------------------------
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: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]