在 Azure Web 应用程序中重写 URL [英] Rewriting a URL in an Azure web app
问题描述
我有一个简单的通配符路由规则,我想为我的 Azure Web 应用申请.
I have a simple wildcard routing rule I want to apply for my Azure web app.
<rule name="MyRule">
<match url="*" />
<action type="Rewrite" url="/index.html" />
</rule>
如果我不能 RDP 进入机器并摆弄 IIS,我在这里有什么选择吗?这不是一个 ASP.Net 网站,它是一个简单的 SPA 应用程序.
Do I have any option here given I can't RDP into the machine and fiddle with IIS? This is not an ASP.Net website, it's a simple SPA application.
推荐答案
您需要在您的 wwwroot 文件夹中创建一个 web.config 文件并将相关的配置条目放在那里.
You need to create a web.config file in your wwwroot folder and put the relevant config entries there.
这是一个 web.config 规则的示例,让您了解它的外观.
Here's an example of an web.config rule, to give you an idea of what it should look like.
以下示例将默认 *.azurewebsites.net 域重定向到自定义域(通过 http://zainrizvi.io/blog/block-default-azure-websites-domain/)
The below example redirect the default *.azurewebsites.net domain to a custom domain (via http://zainrizvi.io/blog/block-default-azure-websites-domain/)
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite.azurewebsites.net$" />
</conditions>
<action type="Redirect" url="http://www.yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这篇关于在 Azure Web 应用程序中重写 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!