[英]IIS URL rewriting fails
I'm trying to implement simple IIS URL rewrite. 我正在尝试实现简单的IIS URL重写。 I want to rewrite URL: about.test.local to text.local/about.html .
我想将URL: about.test.local重写为text.local / about.html 。
In configuration below I have added rules, but it doesn't seem to work. 在下面的配置中,我添加了规则,但似乎不起作用。 What is the problem?
问题是什么?
<rewrite>
<rules>
<rule name="Rewrite1" patternSyntax="ExactMatch" stopProcessing="true">
<match url="about.test.local" />
<action type="Rewrite" url="http://test.local/about.html" />
</rule>
<rule name="Rewrite2" patternSyntax="ExactMatch" stopProcessing="true">
<match url="http://about.test.local/" />
<action type="Rewrite" url="http://test.local/about.html" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
As @beavel mentioned, I have added following rules, but URL still doesn't get rewritten: 如@beavel所述,我添加了以下规则,但是URL仍然没有被重写:
<rule name="Rewrite2a" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="about.test.local" />
</conditions>
<action type="Rewrite" url="http://test.local/about.html" />
</rule>
<rule name="Rewrite2b" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="http://about.test.local/" />
</conditions>
<action type="Rewrite" url="http://test.local/about.html" />
</rule>
The problem is that the match url doesn't contain the host as explained here . 问题是匹配网址不包含此处说明的主机。 If you have multiple hostnames bound to one IIS site and only want to rewrite the one hostname you would do something like:
如果将多个主机名绑定到一个IIS站点,而只想重写一个主机名,则可以执行以下操作:
<rule name="Rewrite1" patternSyntax="ExactMatch" stopProcessing="true">
<match url="(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="about.test.local" />
</conditions>
<action type="Rewrite" url="http://test.local/about.html" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.