2010-11-08 51 views
1

我在我们的生产站点上使用UrlRewrite IIS插件约一个月。IIS UrlRewrite问题

我使用所提供的模板/向导创建一个重定向规则,产生的配置enrty如下:

<rewrite> 
    <rules> 
     <rule name="CanonicalHostNameRule1" enabled="true"> 
      <match url="(.*)" /> 
      <conditions> 
       <add input="{HTTP_HOST}" pattern="^www\.mycompany\.com$" negate="true" /> 
      </conditions> 
      <action type="Redirect" url="http://www.mycompany.com/{R:1}" /> 
     </rule> 
    </rules> 
</rewrite> 

它已经运行良好,直到今天早上,当网站上开始“过多的重定向示数”。据我所知,配置或基础设施中没有任何变化。

我禁用了规则,网站又变得功能了(尽管显然没有任何重定向)。

然后我重新启用规则,现在全部按预期运行。除了临时禁用它之外,我没有对规则做任何修改。

任何想法?插件车?

+0

你在运行什么框架?我知道有一些特别令人不愉快的错误与1.1需要重新启动IIS ... – dooburt 2010-11-08 12:57:25

回答

0

试试这个其他的代码,我有我的网站上,并完美运行:

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

的解释很简单: 匹配任何URL接受处理 的条件是有anydomaintext.extension(您的域名和扩展名)不带前缀 重定向到具有完整前缀的相同域并放置所有网址。

其他尝试是R:1,但退出了一些主要的网址,并没有运行。 来自Ruslani的样本: http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx 我试图使用添加www,但最后使用上面的示例。

0

下面的修复程序适用于我。我发现我的重写规则已经过时了。其他域改变了他们的URL策略并重定向现在从otherdomain.com所有流量www.otherdomain.com

<action type="Rewrite" url="http://otherdomain.com/abc/{R:1}" /> 

<action type="Rewrite" url="http://www.otherdomain.com/abc/{R:1}" /> 

你看到区别?通过添加'www',我抢占了其他域重定向。我基本上只是遵守了他们的新政策。