Reputation: 5012
I have IIS installed on one server and need to have few url rewrite rules. All of the rules have to point to different servers/urls. For example:
http://my-iis-server --> http://web-server-0/category
http://my-iis-server/site1 --> http://web-server-1/category1
http://my-iis-server/site2 --> http://web-server-2/category20
http://my-iis-server/site3 --> http://web-server-3/category33
The first rule was easy. The problems began when trying to implement the rest of the rules (/site1, /site2, /site3
)
If i have the following pattern: Pattern: site1(.*) Rewrite URL: http://web-server-1/{R:1}
and navigate to: http://my-iis-server/site1
the result is 404 and the url is changed to: http://my-iis-server/category1
which dont exists ofc.
Any idea how to keep the siteX
in the main url?
Is this correct approach in general? Is it going to be cleaner/easier with virtual directories?
Upvotes: 0
Views: 801
Reputation: 27997
According to your description, I suggest you could try to use below url rewirte rule:
<rule name="for site 1">
<match url="site1(.*)" />
<action type="Rewrite" url="http://web-server-1/category1{R:1}" />
</rule>
<rule name="for site 2">
<match url="site2(.*)" />
<action type="Rewrite" url="http://web-server-2/category20{R:1}" />
</rule>
<rule name="for site 3">
<match url="site3(.*)" />
<action type="Rewrite" url="http://web-server-3/category33{R:1}" />
</rule>
<rule name="for site 4">
<match url="(.*)" />
<action type="Rewrite" url="http://web-server-0/category" />
</rule>
Upvotes: 1