您能否建议如何解决 URL 重写 Azure Web 应用程序规则的问题?
Could you please advise how to resolve the issue with URL rewrite rules for azure web app?
我在 Azure Web App 上部署了一个 MVC 点网应用程序(多租户平台)。
我已经配置了两个租户:tenant1 和 tenant2,它们的 URL:
- 引物-test.azurewebsites.net/tenant1 和
- 底漆-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>
知道哪里出了问题吗?
非常感谢!
在这种情况下,从您提供的URL,我可以看出primer-test.azurewebsites.net
是您创建和使用的webapp。 tenant1
和 tenant2
在 webapp 中应该是 virtual applications
。
相关帖子:
正确使用流程及测试步骤:
步骤 1.
准备工作,创建一个.net framework的主应用(在项目中使用web.config,目的是配置rewrite。
在门户中配置。
在站点路径下创建文件夹并通过 zip 部署虚拟应用程序。
在不重写设置的情况下进行测试。
第 2 步。修改 RewriteTest
项目中的 web.config
文件。
第 3 步。创建要测试的自定义域。
第四步,测试结果。满足您的需求。
我在 Azure Web App 上部署了一个 MVC 点网应用程序(多租户平台)。 我已经配置了两个租户:tenant1 和 tenant2,它们的 URL:
- 引物-test.azurewebsites.net/tenant1 和
- 底漆-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>
知道哪里出了问题吗?
非常感谢!
在这种情况下,从您提供的URL,我可以看出primer-test.azurewebsites.net
是您创建和使用的webapp。 tenant1
和 tenant2
在 webapp 中应该是 virtual applications
。
相关帖子:
正确使用流程及测试步骤:
步骤 1.
准备工作,创建一个.net framework的主应用(在项目中使用web.config,目的是配置rewrite。
在门户中配置。
在站点路径下创建文件夹并通过 zip 部署虚拟应用程序。
在不重写设置的情况下进行测试。
第 2 步。修改 RewriteTest
项目中的 web.config
文件。
第 3 步。创建要测试的自定义域。
第四步,测试结果。满足您的需求。