Reloading pages with AngularJS served by Apache

I have an Angular app which uses some redirections. Here a snippet from my app.js:

'use strict';

var cacheBustSuffix =;

angular.module('myApp', ['myApp.controllers', '', 'myApp.filters', 'ngRoute', 'ngResource', 'routeStyles'])
        .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
                        .html5Mode({enabled: true,
                            requireBase: false})

                        .when('/', {
                            redirectTo: '/myApp'
                        when('/myApp', {
                            templateUrl: '/partials/home.html?cache-bust=' + cacheBustSuffix,
                            controller: 'ctrlHome'
                        when('/myApp/search', {
                            templateUrl: '/partials/search.html?cache-bust=' + cacheBustSuffix,
                            controller: 'ctrlSearch'
                            templateUrl: '/partials/404.html?cache-bust=' + cacheBustSuffix,
                            controller: 'ctrl404'});

The whole thing is served by Apache 2.4. Here is my .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /index.html [NC,L]

I can manually and automatically reload pages but when I do that looks like the browser re-read only the partial that has to be refreshed, not the index + partial that I'd like to show. As a consequence all the styles and scripts fail to load, and I loose the both the interface and functionality. I think this might be a problem with the .htaccess file but as a beginner with Apache I'm not really confident with it. Anyone knows how to tell the server to re-read both the index.html and the view on refreshes? Thanks.


I think you are just missing to set

    <base href="your/app/path">

in your index.html If you set this tag you will be good to go, also using $locationProvider turn on your html5 mode like this $locationProvider.html5Mode(true); Your .htaccess works fine.

Need Your Help

How to save a list of recent text entries in isolated storage.?

c# silverlight windows-phone-7 windows-phone-7.1

In my app I have a textbox named "msgBox" and a button named "sendBtn".

Laravel 4 Cache::remember is never returning a response with a given ID

php caching laravel-4 shopify database-caching

I am using Laravel 4 in conjunction with the a PHP Shopify connector. I am trying to limit the calls made to retrieve Shopify products by caching the particular product pages when they are first ne...