Mis*_*pic 8 azure azure-web-sites
我有一个简单的通配符路由规则我想申请我的Azure网络应用程序.
<rule name="MyRule">
<match url="*" />
<action type="Rewrite" url="/index.html" />
</rule>
Run Code Online (Sandbox Code Playgroud)
我有没有任何选择,因为我不能RDP进入机器并摆弄IIS?这不是一个ASP.Net网站,它是一个简单的SPA应用程序.
Zai*_*zvi 14
您需要在wwwroot文件夹中创建一个web.config文件,并在其中放置相关的配置条目.
这是一个web.config规则的示例,可以让您了解它应该是什么样子.
以下示例将默认的*.azurewebsites.net域重定向到自定义域(通过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>
Run Code Online (Sandbox Code Playgroud)
如果只想让解析到此服务器和站点的所有URL重定向到index.html您,可以使用此重写部分:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SPA">
<match url=".*" />
<action type="Rewrite" url="index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
除了一些小的语法修复之外,这与你所拥有的非常类似,例如模式应为".*",重写URL目标只是"index.html".请注意,这意味着您的站点的所有URL都将被重写,即使对于CSS和JS文件,图像等其他资源也是如此.因此,您最好从其他域获取资源.
如果您想进行实际的重写(而不是重定向),请不要忘记使用 applicationHost.xdt 文件启用 ARR,并将其放置到具有以下内容的站点文件夹中:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />
<rewrite>
<allowedServerVariables>
<add name="HTTP_ACCEPT_ENCODING" xdt:Transform="Insert" />
<add name="HTTP_X_ORIGINAL_HOST" xdt:Transform="Insert" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17671 次 |
| 最近记录: |