Iis 重写Azure App Service Web.config中的URL以将根目录重定向到index.html
如何匹配根url并将其重定向到index.html? 我试过:Iis 重写Azure App Service Web.config中的URL以将根目录重定向到index.html,iis,url-rewriting,web-config,azure-web-app-service,Iis,Url Rewriting,Web Config,Azure Web App Service,如何匹配根url并将其重定向到index.html? 我试过: <rule name="SPA"> <match url="^$" /> <action type="Rewrite" url="index.html" /> </rule> 及 在Azure应用程序服务中。 但它们没有起作用。我得到:无法得到/ my Web.config: <?xml version="1.0" encoding="utf-8" ?&
<rule name="SPA">
<match url="^$" />
<action type="Rewrite" url="index.html" />
</rule>
及
在Azure应用程序服务中。
但它们没有起作用。我得到:无法得到/
my Web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SPA">
<match url="^$" />
<action type="Rewrite" url="index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我也尝试了重定向。但是没有运气
<rule name="Redirect to canonical url">
<match url="^$" >
<conditions>
<!-- Check whether the requested domain is in canonical form -->
<add input="{HTTP_HOST}" type="Pattern" pattern="^purchasehelper.azurewebsites.net$">
</conditions>
<!-- Redirect to canonical url and convert URL path to lowercase -->
<action type="Redirect" url="http://purchasehelper.azurewebsites.net/index.html" RedirectType="Found"/>
</rule>
您可以尝试在web.config文件中添加和修改以下重写内容:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="index.html" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="index.html" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>