Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config rewrite rule not working in Azure static website in blob storage

I have a single page React app hosted in Azure blob storage but am getting an The requested content does not exist. error when deep linking into a page:

enter image description here

I've enabled static website option in the storage account:

enter image description here

The files are all in place in the $web container:

enter image description here

This includes the following web.config with a rewrite rule that is supposed to let index.html handle all the routing:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="React Routes" 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="/" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Can anyone see where I've gone wrong?

like image 801
Carl Rippon Avatar asked Apr 09 '19 17:04

Carl Rippon


People also ask

How do I host a static website on azure blob storage?

Configure static website hostingOpen the Azure portal in your web browser. Locate your storage account and display the account overview. Select Static website to display the configuration page for static websites. Select Enabled to enable static website hosting for the storage account.

What is retention policy in Azure Blob Storage?

The minimum retention interval for a time-based retention policy is one day, and the maximum is 146,000 days (400 years).


1 Answers

You can do the deep linking if you point the 404 page back at your index.html. This is not a perfect solution - has side effects - but it will work for the majority of cases.

enter image description here

like image 196
Burke Holland Avatar answered Oct 30 '22 06:10

Burke Holland