# injecting a query string into mod_rewrite

## mslinn

I need to translate a URL for a web page with a query string into another URL with a different query string.  The other URLs for the items embedded in the web page should only have their paths translated.

For example, the URL: http:/domain/FDSCD/X?txnId=12345 should map to http:/domain/blah/Main.html?capability=full

Other URLs of the form http:/domain/FDSCD/whatever should map to http:/domain/blah/whatever

This almost works:

```
RewriteEngine on

RewriteCond "%{QUERY_STRING}" "(txnId=.*)"

RewriteRule "/FDSCD/X"     "/blah/Main.html?capability=full" [QSA,L]

RewriteRule "/FDSCD/(.*)"  "/blah/$1" [L]
```

The problem is that the new query string is not injected into the URL - it is computed properly but is then discarded. Log level 8 shows me:

```
(2) init rewrite engine with requested uri /FDSCD/X

(3) applying pattern '/FDSCD/X' to uri '/FDSCD/X'

(4) RewriteCond: input='txnId=x' pattern='(txnId=.*)' => matched

(2) rewrite '/FDSCD/X' -> '/blah/Main.html?capability=full'

(3) split uri=/blah/Main.html?capability=full -> uri=/blah/Main.html, args=capability=full&txnId=x

(2) local path result: /blah/Main.html

(2) prefixed with document_root to /var/home/www/slinnbooks.com/www/production/webapps/ROOT/blah/Main.html

(1) go-ahead with /var/www/production//blah/Main.html [OK]

```

If QSA is not specified, the problem is unchanged - no query string is present in the rewritten URL.

Is there something in mod_proxy that needs to be enabled or configured in order for this to work? Perhaps the Software God requires another sacrifice?

----------

