Unexpected token while refreshing page using Html5Mode

I use Html5Mode(true)AngularJS in my application. This works great when I browse my site as follows:

http://www.example.com

Then it is converted to:

http://www.example.com/home/index

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

# 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]

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?

+4
1

URL- , :

/home - index.html

/product/1234 - index.html

index.html. URL- .

0

All Articles