0

I have a series of url:

http://ip:port/path/page.php?paramN=foo
http://ip:port/path/page.php?paramN=bar?paramy=whatever

... and so on

I need to match the url "as is" and redirect for example the first one to:

http://host1/john.php

The second one to:

http://host2/doe.php

and so on

No regular expressions no rewrite just a thing like an hashmap.

How can I do with a reverse proxy like apache or nginx?

Thanks, Mario

2
  • You want redirect for whole URL or for paramN? May 25, 2017 at 17:26
  • I guess you meant http://ip:port/path/page.php?paramN=bar&paramy=whatever in your example URL. May 26, 2017 at 12:30

1 Answer 1

1

In Apache, if you only need to redirect exact match without regular expressions, you can use mod_alias Redirects and add them in a <Proxy> container before your ProxyPass and ProxyPassReverse.

<Proxy *>
  Redirect /path/page.php?paramN=foo http://host1/john.php
  Redirect /path/page.php?paramN=bar&paramy=whatever http://host2/doe.php
</Proxy>

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/

In this example the http://127.0.0.1:8080/ is made up as you didn't specify what you have there. It's just there for showing the correct order of the directives.

2
  • nginx location paths match only normalized URIs, which do not contain query arguments. Therefore your nginx approach won't work. May 26, 2017 at 12:29
  • Thanks, Tero. I removed the Nginx part – someone else having currently more time can help with that. May 26, 2017 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .