[英]URL Rewriting the path in IIS
I have a site that uses two characters in the URL path to determine the initial language eg https://my.company.net/Monitoring/gb displays in the English language. 我有一个网站,该网站在URL路径中使用两个字符来确定初始语言,例如https://my.company.net/Monitoring/gb以英语显示。 I want to setup a redirect for these two display the full culture code eg https://my.company.net/Monitoring/en-GB
我想为这两个显示完整的文化代码设置重定向,例如https://my.company.net/Monitoring/zh-CN
This is the rule that I've tried: 这是我尝试过的规则:
<rewrite>
<rules>
<rule name="Monitoring gb rewrite" patternSyntax="ExactMatch" stopProcessing="true">
<match url="https://my.company.net/Monitoring/gb" />
<conditions />
<serverVariables />
<action type="Redirect" url="https://my.company.net/Monitoring/en-GB" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I expected https://my.company.net/Monitoring/gb to redirect to https://my.company.net/Monitoring/en-GB however this rule does not have any effect: the browser URL stays at https://my.company.net/Monitoring/gb . 我希望https://my.company.net/Monitoring/gb重定向到https://my.company.net/Monitoring/en-GB,但是此规则没有任何效果:浏览器URL保持在https:/ /my.company.net/Monitoring/gb 。
How can I rectify this? 我该如何纠正?
You could use below url rewrite rule. 您可以使用以下url重写规则。
<rule name="gb to en-gb redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="ww.sample1.com" />
<add input="{HTTPS}" pattern="on" />
<add input="{REQUEST_URI}" pattern="Monitoring/gb" />
</conditions>
<action type="Redirect" url="https://www.sample1.com/Monitoring/en-GB" />
</rule>
Note: use your hostname instead of the www.sample1.com. 注意:使用您的主机名代替www.sample1.com。
The redirect failure was due to browser caching. 重定向失败是由于浏览器缓存。 The redirect works once the cache is cleared.
清除缓存后,重定向即可工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.