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

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.

7
  • Thanks for your reply. However, This is not working. When I access website/solution1/url1, its throwing a 404 error. The URL in the browser becomes 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 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.