Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iis 7 URL重写IIS 7-URL重定向不工作_Iis 7_Url Rewriting - Fatal编程技术网

Iis 7 URL重写IIS 7-URL重定向不工作

Iis 7 URL重写IIS 7-URL重定向不工作,iis-7,url-rewriting,Iis 7,Url Rewriting,我有一个运行在IIS 7上的网站,绑定到端口80,有两个域(出于我们的目的-example.com和test.com)指向它 example.com是我们的标准名称,所以我希望任何点击test.com的客户端都被重定向到example.com 我一直在尝试使用IIS 7重写模块。然而,它似乎没有任何效果。我怎样才能解决这个问题 这是我在web.config中设置的规则 <rewrite> <rules> <rule name="rule1" ena

我有一个运行在IIS 7上的网站,绑定到端口80,有两个域(出于我们的目的-example.com和test.com)指向它

example.com是我们的标准名称,所以我希望任何点击test.com的客户端都被重定向到example.com

我一直在尝试使用IIS 7重写模块。然而,它似乎没有任何效果。我怎样才能解决这个问题

这是我在web.config中设置的规则

<rewrite>
   <rules>
      <rule name="rule1" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*test.com*" />
          <action type="Redirect" url="{R:1}example.com{R:2}" />
      </rule>
   </rules>
</rewrite>

我做得不对。这是一种方法:

<rule name="Canonical Host Name" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
     <add input="{HTTP_HOST}" negate="true" pattern="^www\.example\.com$" />
  </conditions>
  <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>


如果您想将example.com重定向到www.example.com,并使用相同的规则捕获https和http流量,该怎么办?你不想重定向到“http://...“我尝试更换HTTP_主机,但没有成功。有什么想法吗?@Zim博士,但你为什么要这么做?Https用于安全连接,如登录和其他应安全的信息。如果不需要保护,可以使用Http。你为什么要在某个地方同时使用这两种方法呢?让我想到的一件事是,我认为规则评估的输入可能会根据你在网站继承权中创建规则的位置而变化。因此,例如,如果将原始规则嵌套到一个级别,那么如果将其移动到根/默认网站级别,就可以使其正常工作。