【发布时间】:2021-02-24 18:38:34
【问题描述】:
我在 Azure Web App 上部署了一个 MVC 点网应用程序(多租户平台)。 我已经配置了两个租户:tenant1 和 tenant2,它们的 URL:
- primer-test.azurewebsites.net/tenant1 和
- primer-test.azurewebsites.net/tenant2
它们都可以通过 IE、Safari 等访问。我在 GoDaddy 上购买了两个域:
- domain1.com
- domain2.com
我想为他们配置 rewrite 规则,所以每当有人在他的浏览器中输入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>
知道可能出了什么问题吗?
非常感谢!
【问题讨论】:
-
我的回答应该对你很有帮助。如果您需要帮助,请告诉我。
标签: azure url-rewriting web-config azure-web-app-service