iis - URL重写导致重定向你太多次
问题描述
我正在使用 IIS url 重写规则从 IP 地址重定向到具有以下规则的域名。
<rule name="IPHit" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
不幸的是,当我转到https://daart-qa.sandbox.aimsplatform.com/eds-daas时,这会导致无限循环重定向。
如何在没有 dns 条目的无限循环的情况下从 IP 地址重定向?
解决方案
Your rule will redirect 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas/eds-daas. Is that expected behavior?
May I know your only face this infinite loop when you access specific URL or all requests hitted by IP address. What loop URL did you see in web browser developer tool? Post the symtptom of loop URL would help us find the root cause.
Or you need to redirect request 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas? If so you may need two rules side by side.
<rule name="IPHit" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" negate="true" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
<rule name="IP-HIT2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas{C:1}" />
</rule>
推荐阅读
- reactjs - 为什么我的状态在获取数据后没有更新?
- laravel - L5 Swagger - 如何为请求正文或响应正文添加示例
- perforce - 强制如何提交标记为“在头部修订时删除”的文件
- c++ - 尽管项目设置,VS2019 未选择 C++17
- php - 如何使用字符串变量访问静态常量
- jmeter - Jmeter如何在30分钟后从0增加到1500
- node.js - Node.js 在本地工作,但在 Heroku 上一次不行
- python - 我无法使用cherrypy检索cookie:有什么问题?
- sql-server - 我们如何用“AND”在单词和最后一个单词之间添加“逗号”
- django - 如何处理在 celery 中具有多个数据库的 django 应用程序