You need to place the angularjs application in a subfolder of the host. All requests going to the site root should be redirected to a subfolder and if there is no folder or file inside, redirect to index.html while ignoring the path api *. Example: http: // domain / (index.html) rewrite to wwwroot / (index.html). How to write these rules?

  • Good thing you found a solution. But what is the question? - Pavel Mayorov

1 answer 1

Found such a solution:

<rule name="Ignore api" stopProcessing="true"> <match url="(api/.*)"/> <action type="None" /> </rule> <rule name="Redirect to wwwroot"> <match url="(.*)" /> <action type="Rewrite" url="wwwroot/{R:0}"/> </rule> <rule name="Short URLs" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="wwwroot/" /> </rule> 

But with this solution there is one problem, if there is a name of an existing folder in the "wwwroot / ..." on the way, but without a slash at the end, the path is rewritten as "wwwroot / folder name /" and, accordingly, is not.