在 Azure Web 应用中重写 URL [英] Rewriting a URL in an Azure web app

查看:14
本文介绍了在 Azure Web 应用中重写 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的通配符路由规则,我想为我的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆