I deployed an application developed using angular 6 on IIS of windows server. Now I am facing one issue that on navigating the app if I am refreshing the page then it says 404 - File or directory not found. I looked at the posts related to this issue and tried to apply fix. but no luck. I do not want to use # with my urls. I just want to use urls simply like http://example.xyz.com/detail/12
If I am using # then its fine but I don't want to use #.
I tried to add a web.config as well, but no luck. Can any one help here how to fix this issue so that on refresh same page can be opened that I want to reload.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular 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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Follow this link to fix this issue Angular 2 Hosted on IIS: HTTP Error 404 or just
Step 1: Install IIS URL Rewrite Module
Step 2: Add a rewrite rule to web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS 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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With