在 IIS7 中根据 IP 掩码在两个文件夹之间重定向用户
redirect user in IIS7 between two folders depending on IP mask
假设我有 Default Web Site
和文件夹。
粗略地说,这棵树看起来像这样:
|- Server
|- Default Web Site
|- folder1
|- folder2
我想根据用户的 IP 掩码将用户重定向到我网站中的不同文件夹。
例如,如果用户的 IP 具有以下模式:
- 10.10.10.* IIS has to redirect to "folder1"
- 11.11.11.* IIS has to redirect to "folder2"
这可能吗?如果是,那又如何?
<rule name="RedirectBySourceIP1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="10.10.10.(.*)" />
<add input="{URL}" pattern="folder1(.*)" negate="true" />
</conditions>
<action type="Redirect" url="/folder1" />
</rule>
<rule name="RedirectBySourceIP2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="11.11.11.(.*)" />
<add input="{URL}" pattern="folder2(.*)" negate="true" />
</conditions>
<action type="Redirect" url="/folder2" />
</rule>
假设我有 Default Web Site
和文件夹。
粗略地说,这棵树看起来像这样:
|- Server
|- Default Web Site
|- folder1
|- folder2
我想根据用户的 IP 掩码将用户重定向到我网站中的不同文件夹。
例如,如果用户的 IP 具有以下模式:
- 10.10.10.* IIS has to redirect to "folder1"
- 11.11.11.* IIS has to redirect to "folder2"
这可能吗?如果是,那又如何?
<rule name="RedirectBySourceIP1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="10.10.10.(.*)" />
<add input="{URL}" pattern="folder1(.*)" negate="true" />
</conditions>
<action type="Redirect" url="/folder1" />
</rule>
<rule name="RedirectBySourceIP2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="11.11.11.(.*)" />
<add input="{URL}" pattern="folder2(.*)" negate="true" />
</conditions>
<action type="Redirect" url="/folder2" />
</rule>