This question already has an answer here:
I also tried by setting the $locationProvider.html5Mode(true);
in ui-routing and base href to <base href="http://localhost/rootfoldername/">
it removes hash but on refresh it gives 404 Error.
Please help me out...
As others said enabling html5 mode and adding a baseURL does the trick, however one piece of the puzzle is still missing and thats the rewrite rules configuration for your server.
The reason why the 404 is thrown is because the server doesn't redirect all routes to the angularJS app. This is where rewrite rules come on.
For apache: How to rewrite url in apache htaccess for angularjs app
For IIS: How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?