React app deployed to IIS StaticFile handler problem


I have a sample React application. I deployed the application to IIS. Default page is OK, but /category page returns 404 - File or directory not found.

import { Route, BrowserRouter } from "react-router-dom";

const Home = () => (

const Category = () => (

export default function App() {
  return (
        <Route path="/"><Home /></Route>
        <Route path="/category"><Category /></Route>

Web.config file content. runAllManagedModulesForAllRequests solution not working unfortunately.

<?xml version="1.0" encoding="UTF-8"?>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="UrlRoutingModule"/>

Detailed Error Information

  • Module: IIS Web Core
  • Notification: MapRequestHandler
  • Handler: StaticFile
  • Error Code 0x80070002

ny suggestion please

asked on Stack Overflow Apr 7, 2021 by selami

1 Answer


Using URL rewrite modul, redirect all requests to index.html file.

<?xml version="1.0"?>
 <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" />
 <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
 <action type="Rewrite" url="/" />
answered on Stack Overflow Apr 7, 2021 by selami

User contributions licensed under CC BY-SA 3.0