Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Web.config for single page application push state in IIS (credit to Matt McCabe)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="pushState" />
<rule name="pushState" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
@tsauvajon

This comment has been minimized.

Copy link

@tsauvajon tsauvajon commented Aug 1, 2018

Do you know how to ignore certain paths (for exemple the static folder) for the redirection ?

EDIT : answered by https://www.mattburkedev.com/iis-rewrite-rule-for-single-page-apps/

<add input="{REQUEST_URI}" pattern="(static)" negate="true" />

I also had to change the rewrite url from / to path/to/my/application.
ie. my address is http://server/platform/application, so I wrote the following rewrite rule:

<action type="Rewrite" url="/platform/application" />
@mataprasad

This comment has been minimized.

Copy link

@mataprasad mataprasad commented Jun 22, 2020

Thanks worked like charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment