Redirect web.config通过ip重定向
为了网站安全,我想使用web.config将单个IP地址或几个IP地址重定向到不同的域。我是新来的。我知道如何限制访问或阻止某些IP,但有没有简单的方法重定向?谢谢 要重定向特定IP地址,您需要使用适用于IIS 7的 有关如何按IP地址重定向的说明,请查看此链接:Redirect web.config通过ip重定向,redirect,web-config,ip,security,ip-address,Redirect,Web Config,Ip,Security,Ip Address,为了网站安全,我想使用web.config将单个IP地址或几个IP地址重定向到不同的域。我是新来的。我知道如何限制访问或阻止某些IP,但有没有简单的方法重定向?谢谢 要重定向特定IP地址,您需要使用适用于IIS 7的 有关如何按IP地址重定向的说明,请查看此链接: 无法回复Victor的评论,因此我将把编辑的代码放在这里,而不是建议更改 <rewrite> <rules> <rule name="Imported Rule 1" stopProcess
无法回复Victor的评论,因此我将把编辑的代码放在这里,而不是建议更改
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="(.*)$" ignoreCase="false" />
<conditions>
<add input="{REMOTE_HOST}" pattern="^123\.123\.123\.123" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://www.domain-to-redirect-to/coming-soon.html" />
</rule>
</rules>
</rewrite>
这里的变化是,它根据询问者的需要重定向到一个新域,而不是同一域上的页面
请注意,如果要重定向到同一域上的coming-soon.html,则需要更改匹配规则,否则将进入重定向循环
因此:
谢谢你,维克多。有没有办法只重定向来自特定IP的请求?
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="(.*)$" ignoreCase="false" />
<conditions>
<add input="{REMOTE_HOST}" pattern="^123\.123\.123\.123" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://www.domain-to-redirect-to/coming-soon.html" />
</rule>
</rules>
</rewrite>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="(.*)coming-soon.html$" ignoreCase="false" negate="true" />
<conditions>
<add input="{REMOTE_HOST}" pattern="^123\.123\.123\.123" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="/coming-soon.html" />
</rule>
</rules>
</rewrite>