httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <>
Subject Re: [users@httpd] using mod_rewrite to change param value
Date Fri, 10 Nov 2006 18:48:50 GMT
On 11/10/06, DM <> 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:
> to
> 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 ""
> - 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}
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.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message