-
-
Save maxan/0d124ed677ebe41e1aeaf4a9e1e6aa45 to your computer and use it in GitHub Desktop.
<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" /> | |
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="/" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
OR | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="Rewrite Text Requests" stopProcessing="true"> | |
<match url=".*" /> | |
<conditions> | |
<add input="{HTTP_METHOD}" pattern="^GET$" /> | |
<add input="{HTTP_ACCEPT}" pattern="^text/html" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="/index.html" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
OR | |
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="DynamicContent"> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> | |
</conditions> | |
<action type="Rewrite" url="index.html"/> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
Adding the config file to the build folder worked for me
where is this web.config located, I publish with VS 2019 to IIS and it load up the app but only root and no routs work. In the SPA public folder I see a web.config and change that adding this OP xml but no change to SPA behavior. in the wwwroot the VS 2019 Publish feature is creating a web.config also but that one is write protected so how do you guys do this?
Hello, i have react app deployed on iis with asp.net. I had the same probleme, my website worked perfectly but i can't refresh my page, so i installed url rewrite and added web.config but it get worst, i can't even log in to my website or anything else. Can someone help me please?
The issue for me was that web.config was not being copied into the build folder, I updated my github workflow like so:
- name: npm install, build, and test
run: |
yarn install
yarn run build
**cp Web.config ./build/Web.config**
npm run test --if-present```
Try download and installing rewrite_amd64.msi.. I was facing the same issue, but after installing rewrite_amd64.msi for IIS.. it worked for me.. Hope it helps.. :)