0

I have the following Apache rewrite rule:

RewriteRule ^(.*)$ http://127.0.0.1:8002$1 [P,L,NC]

The intention is to forward all incoming URL's to local port 8002 where an Express app is listening for incoming requests. The issue is that this rule forwards the base URL but not the query string parameters.

For example, it when Apache sees http://example.com/test/, Express sees http://example.com/test/ but when Apache sees http://example.com/test/?a=b, Express still sees http://example.com/test/.

How do I pass along the query string to port 8002?

Gaurav Sharma
  • 4,032
  • 14
  • 46
  • 72

2 Answers2

0

Not sure if this is the best solution, but you could do:

RewriteRule ^(.*)$ http://127.0.0.1:8002$1?%{QUERY_STRING} [P,L,NC]
0

Looks like the correct way to do this is add the QSA flag as answered at https://stackoverflow.com/a/12873205/82135

So,

RewriteRule ^(.*)$ http://127.0.0.1:8002$1 [P,L,NC,QSA]

works now.

Community
  • 1
  • 1
Gaurav Sharma
  • 4,032
  • 14
  • 46
  • 72