I use Html5Mode(true)AngularJS in my application. This works great when I browse my site as follows:
http:
Then it is converted to:
http:
And my page is displayed perfectly.
But when I press F5, I get a lot of errors in the console window:
Resource interpreted as Script but transferred with MIME type text/html: "http://www.example.com/home/js/jquery/jquery.min.js". index:22
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://www.example.com/home/js/slider/angular.rangeSlider.css". index:16
Uncaught SyntaxError: Unexpected token < jquery.min.js:1
Resource interpreted as Script but transferred with MIME type text/html: "http://www.example.com/home/js/angular/angular-resource.min.js". index:25
Resource interpreted as Script but transferred with MIME type text/html: "http://www.example.com/home/js/angular/angular.min.js". index:24
Uncaught SyntaxError: Unexpected token < angular.min.js:1
Uncaught SyntaxError: Unexpected token < angular-resource.min.js:1
Resource interpreted as Script but transferred with MIME type text/html: "http://www.example.com/home/js/angular/angular-cookies.min.js". index:26
Uncaught SyntaxError: Unexpected token <
I already configured my file .htaccessas follows:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(.*) /index.html [L]
But this does not work when I refresh the page. Then I get errors. Is something missing?
I use ui-router. Not sure if that matters. My route looks something like this:
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/home/index');
$stateProvider
.state('home', {
abstract: true,
url: '/home',
templateUrl: '/tpl/home.html'
})
.state('home.index', {
url: '/index',
templateUrl: '/tpl/home_index.html'
})
Any idea why updating the page results in the errors I posted above?