【问题标题】:Redirect Azure custom domain to external domain (Google domain)将 Azure 自定义域重定向到外部域(Google 域)
【发布时间】:2020-03-09 23:28:57
【问题描述】:
我有指向我的应用服务的 myazurecustomdomain.com,我有指向我的应用服务的资源记录的 mygoogledomain.ca。我已将这两个域分配给我的天蓝色应用程序。
现在我希望将 myazurecustomdomain.com 重定向到 mygoogledomain.ca,因为我有一些第三方库订阅了我的 .ca 域,而我现在不一定要维护我的 .com 域。最好的方法是什么。
【问题讨论】:
标签:
azure
dns
azure-web-app-service
appdomain
【解决方案1】:
如果您现在不想维护.com 域,您可以删除自定义域mapped to your app service。因此,您将可以通过当前自定义域 mygoogledomain.ca 或默认应用服务域(如 xxx.azurewebsites.net)访问该 Web 应用。
当您有两个自定义域 mapped 到您的 azure 应用服务时,您希望将一个域重定向到另一个域。您可以在应用程序的 web.config 文件中添加重写规则。更多信息,您可以参考this answer。
<rewrite>
<rules>
<rule name="Redirect all to different domain" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^myazurecustomdomain.com$" />
</conditions>
<action type="Redirect" url="http://mygoogledomain.ca/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>