在Azure网站中将非WWW重定向到WWW [英] Redirecting non-WWW to WWW in an Azure Website
本文介绍了在Azure网站中将非WWW重定向到WWW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Godaddy拥有一个域,并且在Azure网站基础结构上拥有一个网站.我要实现的是仅使用域的www版本.如果用户在浏览器中输入"example.com",我希望将他们重定向到"www.example.com".
I have a domain with Godaddy, and a website on the Azure websites infrastructure. What I want to achieve is to use only the www version of my domain. If a user enters "example.com" in their browser I want them to be redirected to "www.example.com".
该站点将托管ASP.Net MVC 5应用程序(如果有所作为).我该如何配置?
The site is hosting a ASP.Net MVC 5 app if that makes a difference. How do I configure this?
推荐答案
在<system.webServer>
部分下将此代码添加到此代码中
add this code this code under <system.webServer>
section
<rewrite>
<rules>
<rule name="Redirect to www">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
这篇关于在Azure网站中将非WWW重定向到WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文