IIS configuration for using angular ui routing htm

2019-04-15 04:05发布

问题:

Im using angular ui-routing but for the most encountered problem reason I want to ask something. Because of using '#' hashtag I prefered html5Mode property. But server side conf. is needed.(https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode) I m using IIS and I put the :

 <rewrite>
  <rules>
    <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" />
      </conditions>
      <action type="Rewrite" url="/" />
    </rule>
  </rules>
</rewrite>

and install one tool which is mentioned another topic on stackoverflow (How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?). But now I m getting : HTTP Error 403.18 - Forbidden The specified request cannot be processed in the application pool that is configured for this resource on the Web server.I m really spend my most of time for hashtag problem :( Please help me . What is the missing?

回答1:

<match url=(.*)>
..
..
..
<action type=“Rewrite” url=“/{R:0}”>

Change these two lines and try as the rewrite should be backward resource compatible