Skip to content

Instantly share code, notes, and snippets.

@markylaredo
Created February 3, 2021 09:42
Show Gist options
  • Save markylaredo/db243eddd618f7843c4a32727e4f6ac9 to your computer and use it in GitHub Desktop.
Save markylaredo/db243eddd618f7843c4a32727e4f6ac9 to your computer and use it in GitHub Desktop.
IIS Web configuration for SPA websites
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<!-- unless its a file -->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<!-- or a directory -->
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<!-- or is under the /api directory -->
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<!-- list other routes or route prefixes here if you need to handle them server side -->
</conditions>
<!-- rewrite it to /index.html -->
<action type="Rewrite" url="/index.html" />
</rule>
<rule name="HTTP Force" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="SPA Routes" stopProcessing="true">
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
<!--ProjectGuid: E47EB803-9301-4E34-9788-0644F7ACE408-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment