我使用ASP.net MVC并且我在arvixe中使用websitepanel和我的托管现在我需要使用www.example.com
打开我的网站
现在我的网站打开了2个网址:
www.example.com
example.com
我需要只用一个网址打开它:www.example.com
这样
当用户输入example.com
作为网址时,它会转到www.example.com
我如何在web.config
或websitepanel配置中执行此操作?
我无法访问IIS。
答案 0 :(得分:0)
Hopefully the same will still apply to your setup but I add the following to the live web.config
. It will ensure a 301 redirect from non-www to www prefixed domain:
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
...
</system.webServer>