Search code examples
javascriptangularjsurl-rewritinglocation-provider

Angular js - LocationProvider HTML5mode() and urls


i've enabled the

locationProvider.HTML5mode(true);

then i putted on top of index.html :

<html ng-app="app">
<head>
 <base href="/projects/www/#/" />

So if i browse the site using internal links for example(#/users) everything works and urls are re-writed from projects/www/#/users to projects/www/users

BUT if i go directly by browser to projects/www/users i get page not found.

The only one direct url that works is :

projects/www/

What this could be?


Solution

  • Ok i fixed it was to add some server side htaccess code:

    RewriteEngine on
    RewriteBase /Projects/www
    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    
    # Rewrite everything else to index.html to allow html5 state links
    RewriteRule ^ index.html [L]