gpt4 book ai didi

azure - 您能否建议如何解决 azure Web 应用程序的 URL 重写规则问题?

转载 作者:行者123 更新时间:2023-12-03 03:55:19 25 4
gpt4 key购买 nike

我在 Azure Web App 上部署了一个 MVC dot net 应用程序( Multi-Tenancy 平台)。我配置了两个租户:tenant1 和tenant2,及其 URL:

  1. primer-test.azurewebsites.net/tenant1 和
  2. primer-test.azurewebsites.net/tenant2

这两个域名都可以通过 IE、Safari 等访问。我在 GoDaddy 上购买了两个域名:

  1. 域名1.com
  2. domain2.com

我想为它们配置重写规则,以便每当有人在浏览器中输入 www.domain1.com 时或domain1.com,应显示primer-test.azurewebsites.net/tenant1 的内容。同样,对于domain2。

我已将这两个自定义域附加到我的网络应用程序中,没有任何问题。我编写了重写规则,但它们似乎没有按预期工作。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>
<rule name="domain1.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?domain1.com" />
<add input="{PATH_INFO}" pattern="^/tenant1/" negate="true" />
</conditions>
<action type="Rewrite" url="\tenant1\{R:0}" />
</rule>
<rule name="domain2.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?domain2.com" />
<add input="{PATH_INFO}" pattern="^/tenant2/" negate="true" />
</conditions>
<action type="Rewrite" url="\tenant2\{R:0}" />
</rule>
</rules>
</rewrite>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\kobsq.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</location>
</configuration>

知道可能出了什么问题吗?

非常感谢!

最佳答案

在本例中,从您提供的 URL 中,我可以看到 primer-test.azurewebsites.net 是您创建和使用的 Web 应用。 tenant1tenant2 应该是 web 应用程序中的虚拟应用程序

概念: Virtual application

相关帖子:

1. How to deploy a Flask+React application to Azure Web Service

2. Hosting Two Website Under one Web App - Azure Services

正确的使用流程及测试步骤:

第 1 步。

准备工作,创建一个.net框架的主应用(在项目中使用web.config用于配置rewrite。

enter image description here

在门户中配置。

enter image description here

在站点路径下创建文件夹并通过 zip 部署虚拟应用程序。

enter image description here

enter image description here

enter image description here

在不重写设置的情况下进行测试。

enter image description here

第2步.修改RewriteTest项目中的web.config文件。

enter image description here

第 3 步:创建要测试的自定义域。

enter image description here

步骤 4. 测试结果。满足您的需求。

enter image description here

关于azure - 您能否建议如何解决 azure Web 应用程序的 URL 重写规则问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64809315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com