Up:: Angular

Angular 404 on refresh

Add this to the .htaccess file:

Options +FollowSymLinks
 
<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>
 

For windows, add this to the web.config in the root of the application:

<?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>

📇 Additional Metadata