2011-10-03 85 views
0

我试图将我的网站从www.example.com重定向到example.com,下面的代码但我得到500错误。Webconfig从www.example.com重定向到http://example.com

<system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Redirect from WWW" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="^www.example.com$" /> 
      </conditions> 
      <action type="Redirect" url="http://example.com/{R:0}" redirectType="Permanent" /> 
     </rule> 
    </rules> 
    </rewrite> 
</system.webServer> 

请你让我知道我的代码有什么问题吗?

回答

1

您的DNS服务器设置为解决example.com,没有www?

这可能是你的问题

+0

Paulo,它不可能,因为如果有人在地址之前输入www会得到错误。我想如果有人输入www重定向到http://自动。 – Jay

+0

我知道。但我在想,如果你有WWW.site和site指向同一个位置,你不会得到那个错误。或者你可以在IIS上用www设置一个新网站,指向没有的网站。当您创建网站时,在IIS上右键单击Propeties并选择“主目录”选项卡,您可以选择重定向到URL。 只是一个希望,希望可以帮助 干杯 –

相关问题