Skip to content

Instantly share code, notes, and snippets.

@freshcutdevelopment
Last active May 8, 2022 14:05
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save freshcutdevelopment/8df4ee8cb7470b3e18d3236931b46d97 to your computer and use it in GitHub Desktop.
Save freshcutdevelopment/8df4ee8cb7470b3e18d3236931b46d97 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

Thanks worked like charm.

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