SOLUTION for Angular 404 Not Found error on refresh or redirect
Sometimes when we create a production version of angular app , We can face a issue of 404 not found
Why 404 not found error showing on redirection on other page or on refresh ?
Angular is SPA(single page application) so it use html5 history for redirection and we refresh or redirect , its not able to find that routes thats why it shows an error of not found
Solution
We can solve this issue by multiple ways but one of the easiest way is using htaccess. So if you are using Apache server then you can create a file on your root folder and put below content in it
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
Now save this file and try to refresh or navigate to another page, It will work.
Comments
Post a Comment