Angular gets 404 after refresh when using Path Location Strategy

Posted in Articles

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

If you are using path location strategy for routes in Angular, you might notice that after refreshing a secondary page, you get a 404 error.

This is because the path doesn’t really exist on the server.   You need to redirect it to your site Angular root page and then it can take care of the routing.

This article linked here has code for the .htaccess file in Apache to perform this redirect.

The RewriteCond checks if assets exists or not.  If not, redirect to root page.


Related Posts

Tags

Share This