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

查看:101
本文介绍了在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域重定向到自定义域(通过

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天全站免登陆