-1

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

georgeawg
  • 48,608
  • 13
  • 72
  • 95

1 Answers1

2

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?

bramve
  • 147
  • 10
  • Hi tried putting the rewrite code in htaccess still i am getting same 404 error on refresh.`RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^(.*) /index.html [NC,L]` – manishkummar Mar 16 '18 at 09:47
  • Make sure that the /index.html which the rewrite rule points to actually exists and contains the angular app. If that still doesn't work you might want to add additional information to your question so we can help you out further, like maybe even a screenshot of the 404 error page. – bramve Mar 16 '18 at 10:11
  • My Code Structure :- apache>htdocs>projectname>both index.html and .htaccess present , Is there mistake please let me know. – manishkummar Mar 16 '18 at 10:15