Angularjs 如何在同一站点上永久重定向和重写规则
在我的web.config中,我为AngularJS(HTML5模式)设置了此规则Angularjs 如何在同一站点上永久重定向和重写规则,angularjs,redirect,web-config,rewrite,Angularjs,Redirect,Web Config,Rewrite,在我的web.config中,我为AngularJS(HTML5模式)设置了此规则 然后我有一个301重定向负载设置如下: <location path="about.html"> <system.webServer> <httpRedirect enabled="true" destination="/about" httpResponseStatus="Permanent" /> </system.webServer> &l
然后我有一个301重定向负载设置如下:
<location path="about.html">
<system.webServer>
<httpRedirect enabled="true" destination="/about" httpResponseStatus="Permanent" />
</system.webServer>
</location>
显然,没有达到重定向。我如何让我的重写器只应用于任何没有被重定向的东西
我希望这是有道理的
使现代化
我删除了重写规则,只是为了测试重定向在没有它的情况下是否工作。是的,但我的应用程序仍在运行。
我确信我需要HTML5模式的重写规则。不是这样吗
更新2
似乎重写器是用于url参数的。我不知道的是,您可以向重写规则添加重定向。如果您首先添加它们,并将停止处理标志设置为true,它将重定向而不是“命中”重写规则 以下是一个例子:
<rules>
<rule name="301" stopProcessing="true">
<match url="volleyball" />
<action type="Redirect" url="/" redirectType="Permanent" />
</rule>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/token" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
<rules>
<rule name="301" stopProcessing="true">
<match url="volleyball" />
<action type="Redirect" url="/" redirectType="Permanent" />
</rule>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/token" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>