Question

We have a JSP application that uses a url like this...

https://subdomain.domain.com/project/page.jsp?a=param1&b=param2

This is a vendor product and since I am not allowed to just add JAX-RS throw a PathParam and be done with it, I have to figure and Apache rule (I am using IHS technically) or something to translate it into...

https://othersubdomain.domain.com/param1/param2

What is the best way to handle this without editing the webapp?

Sorry in advance if this is a repeat somewhere.

Was it helpful?

Solution

In the SSL vhost that handles the request, you can try something like this -- but it is quite specific to the source and target URLs:

RewriteEngine on
RewriteCond %{HTTP_HOST} =subdomain.domain.com
RewriteCond %{QUERY_STRING} ^a=([^&]+)&b=([^&]+)
RewriteRule ^/project/page.jsp$ /%1/%2 [PT,E=CHANGEHOST:1]
RequestHeader set Host othersubdomain.domain.com env=CHANGEHOST

If you can just redirect, you would skip the last line and just build a URL in the RewriteRule and drop the current flags for [L]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top