1

How can I match the root url and redirect it to index.html? I have tried:

<rule name="SPA">
    <match url="^$" />
    <action type="Rewrite" url="index.html" />
</rule>

and

<rule name="SPA">
    <match url="" />
    <action type="Rewrite" url="index.html" />
</rule>

in Azure App Service. But they didn't work. I got: Cannot GET /

my Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="SPA">
                    <match url="^$" />
                    <action type="Rewrite" url="index.html" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I tried Redirect as well. But no luck.

<rule name="Redirect to canonical url">
<match url="^$" >
<conditions>
   <!-- Check whether the requested domain is in canonical form -->
   <add input="{HTTP_HOST}" type="Pattern" pattern="^purchasehelper.azurewebsites.net$">
</conditions>
<!-- Redirect to canonical url and convert URL path to lowercase -->
<action type="Redirect" url="http://purchasehelper.azurewebsites.net/index.html" RedirectType="Found"/>
</rule>

1 Answer 1

3

You can try to add and modify the following rewrite content in web.config file:

<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
 <system.webServer>
 <rewrite>
 <rules>
<rule name="Index Request" enabled="true" stopProcessing="true">
 <match url="^$" />
 <action type="Redirect" url="index.html" logRewrittenUrl="true" />
 </rule>
</rules>
 </rewrite>
 </system.webServer>
 </configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.