title: How to enable React routing in IIS?
body: <p>The following component is loaded from App.js of my React application.</p>
  
  <pre><code>const Main = () =&gt; (
    &lt;BrowserRouter&gt;
      &lt;Switch&gt;
        &lt;Route exact path="/:userid" component={Banks} /&gt;
      &lt;/Switch&gt;
    &lt;/BrowserRouter&gt;
  );
  </code></pre>
  
  <p>When the application is run using local development server, I am able to get userid from the following url:</p>
  
  <p><a href="http://myAppPath/100" rel="nofollow noreferrer">http://myAppPath/100</a></p>
  
  <p>However, when I build the application and host it in IIS, I am not able to get the userid. </p>
  
  <p><a href="https://localhost/Bank/100" rel="nofollow noreferrer">https://localhost/Bank/100</a> --> UPDATED HTTP TO HTTPS</p>
  
  <p>The routing is not recognized. I used URL Rewrite but the value of userid is still not coming in.</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;rewrite&gt;
          &lt;rules&gt;
              &lt;rule name="Routing" enabled="true" stopProcessing="true"&gt;
                  &lt;match url=".*" /&gt;
                  &lt;conditions&gt;
                      &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
                      &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
                  &lt;/conditions&gt;
                  &lt;action type="Rewrite" url="/" logRewrittenUrl="true" /&gt;
              &lt;/rule&gt;
          &lt;/rules&gt;
      &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>index.html:</p>
  
  <pre><code>&lt;!doctype html&gt;&lt;html lang="en"&gt;&lt;head&gt;&lt;meta charset="utf-8"&gt;&lt;meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"&gt;&lt;meta name="theme-color" content="#000000"&gt;&lt;link rel="manifest" href="./manifest.json"&gt;&lt;link rel="shortcut icon" href="./favicon.ico"&gt;&lt;title&gt;Bank App&lt;/title&gt;&lt;link href="./static/css/main.b730bb13.css" rel="stylesheet"&gt;&lt;/head&gt;&lt;body&gt;&lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;&lt;div id="root"&gt;&lt;/div&gt;&lt;script type="text/javascript" src="./static/js/main.2564873f.js"&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>