首页 > 解决方案 > 如何将请求重定向到通过 Azure 应用服务托管的不同 Web 应用

问题描述

我有两个通过 Azure Web 服务托管的 Web 应用程序,分别带有 URLhttps://example1.azurewebsites.nethttps://example2.azurewebsites.net

我正在看的是我想将请求重定向example1到,example2而不需要任何代码更改或重新部署。我不太确定 Azure Web 服务是否支持这种开箱即用的配置。如果是这样,最好的选择是什么?

更新:为了澄清,所有请求的 URL 都需要更改为example2from example1

标签: azureredirect.net-coreazure-web-app-serviceazure-webapps

解决方案


最简单的方法是使用重定向规则更新您的 web.config。您甚至可以在 WebApp 的 SCM 站点中编辑 web.config,甚至无需 FTP 进入或重新部署。这是微软文档

这段代码应该可以做到,但我还没有测试过。

<system.webServer>
   <httpRedirect enabled="true" destination="http://www.contoso.com/" />
</system.webServer>

推荐阅读