IIS 在 asp.net 中重写 URL 进入无限循环
IIS rewrite URL in asp.net goes to into infinity loop
我只需要在我的网络配置文件中创建一个规则,将所有 URL 重写到规则中
例如:
url/services/presentations-evenementielles 到
url/Services/Presentations-Evenementielles
这一切都是为了 SEO 目的而制作的,以避免重复。
<rule name="ProductionRule2" stopProcessing="true" patternSyntax="ExactMatch" >
<match url="^/productions/xyz" ignoreCase="true" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent"/>
</rule>
上面的代码给了我无限循环错误。
您的规则有一些错误
1.You 试图在完全匹配规则中使用“^”。请设置为正则表达式
2.You 正试图在匹配 url 中使用“/”。 domain/productions/xyz 的匹配 url 部分是
productions/xyz 而不是 /production/xyz.
3.You 将在您将 URL 重定向到自身时启用忽略大小写。
所以请尝试这样修改规则
<rule name="ProductionRule2" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^productions/xyz" ignoreCase="false" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent" />
</rule>
更新:
请这样修改规则
<rule name="ProductionRule2" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^Productions/XYZ" ignoreCase="false" negate="true" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent" />
<conditions>
<add input="{ToLower:{URL}}" pattern="/productions/xyz" />
</conditions>
</rule>
这对我有利
请记住在测试 rule.And 时清理浏览器缓存 URL 应该是 prODuctions/Xyz 而不是 prODuction/Xyz。
我只需要在我的网络配置文件中创建一个规则,将所有 URL 重写到规则中
例如: url/services/presentations-evenementielles 到 url/Services/Presentations-Evenementielles
这一切都是为了 SEO 目的而制作的,以避免重复。
<rule name="ProductionRule2" stopProcessing="true" patternSyntax="ExactMatch" >
<match url="^/productions/xyz" ignoreCase="true" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent"/>
</rule>
上面的代码给了我无限循环错误。
您的规则有一些错误
1.You 试图在完全匹配规则中使用“^”。请设置为正则表达式
2.You 正试图在匹配 url 中使用“/”。 domain/productions/xyz 的匹配 url 部分是 productions/xyz 而不是 /production/xyz.
3.You 将在您将 URL 重定向到自身时启用忽略大小写。
所以请尝试这样修改规则
<rule name="ProductionRule2" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^productions/xyz" ignoreCase="false" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent" />
</rule>
更新:
请这样修改规则
<rule name="ProductionRule2" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^Productions/XYZ" ignoreCase="false" negate="true" />
<action type="Redirect" url="Productions/XYZ" redirectType="Permanent" />
<conditions>
<add input="{ToLower:{URL}}" pattern="/productions/xyz" />
</conditions>
</rule>
这对我有利
请记住在测试 rule.And 时清理浏览器缓存 URL 应该是 prODuctions/Xyz 而不是 prODuction/Xyz。