2

I have two processes/apps running on port 8888 & port 8890.

I can access them in my windows server with http://localhost:8888 & http://localhost:8890.

I am currently using IIS GUI for rewriting URLs. Application Request Routing(ARR) & URL Rewrite are installed.

I have been successful in rewriting or redirecting all requests which hit the server to one port - essentially I map '*' wildcard to 'http://localhost:8888/{R:0}' and it works when I access http://website!

How can I extend this to the following scenario:

http://website/solution1/ should redirect to port 8888 & http://website/solution2/ should redirect to port 8890

Please help.

1 Answers1

1

Something like this (in your web.config) should work:

<rule name="solution1" stopProcessing="true">
    <match url="^(solution1/)(.*)" />
    <action type="Rewrite" url="http://localhost:8888/{R:2}" />
</rule>
<rule name="solution2" stopProcessing="true">
    <match url="^(solution2/)(.*)" />
    <action type="Rewrite" url="http://localhost:8890/{R:2}" />
</rule>

IIRC, the {R:0} will match the entire URL, so you don't want that in this case. Instead, with the ( and ) you define 'capturing groups'; {R:2} will be everything after solution1/ or solution2/.

If you're set on using the IIS GUI, I hope you'll be able to find the fields that need to be filled; they are the same ones you already use, only with different parameters.

Glorfindel
  • 1,213
  • 4
  • 15
  • 22
  • Thanks for your reply. However, This is not working. When I access http://website/solution1/url1/, its throwing a 404 error. The URL in the browser becomes http://website/url1/. So I guess the rewrite happens but it doesn't work as intended. – Vijay Yellepeddi Oct 29 '17 at 11:10
  • Do you get the same 404 when visiting http://localhost:8888/url1 ? – Glorfindel Oct 29 '17 at 11:11
  • Yes. I do get a 404. – Vijay Yellepeddi Oct 29 '17 at 11:23
  • Can you check with a localhost:8888 URL which *does* work? – Glorfindel Oct 29 '17 at 11:24
  • Is there any setting I have to enable in ARR? I have checked the "Enable Proxy" checkbox. But I haven't checked the "Use URL Rewrite to check incoming requests". Do I have to enable it? – Vijay Yellepeddi Oct 29 '17 at 11:24
  • I often forget to switch on the "Enable Proxy". In my setup, it works without "Use URL Rewrite to check incoming requests". – Glorfindel Oct 29 '17 at 11:27
  • URLs in the browser are not supposed to change when rewrite is configured. I’m guessing your rule may have a redirect instead lf rewrite as the action type? – milope Nov 01 '17 at 11:08