After reading a ton of write-ups and stackoverflow questions on Angular.js route, I\'m still getting the \'Not Found\' error when I do a manual refresh.
Steps:
This .htaccess setting worked well for me
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) /#!/$1 [NE,L,R=301]
</IfModule>
I couldn't comment but as well as using HTML mode
, base href="/"
, sudo a2enmod rewrite
, using .htaccess
rewrite. From Unispaw, I had to AllowOverride All
in both the sites available of your site and the /etc/apache2 apache.conf
I don't know if this is the optimal solution, but I did find a combination of settings that worked:
hashPrefix('!')
(see below) <base href="/">
in my index.htmlFallbackResource /index.html
to my <Directory PATH_TO_WWW_FILES>
section in my server .conf
file per this post. After setting this, it didn't seem to matter what the local mod_rewrite
settings were.// Routing configuration.
angular.module('myModule')
.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
// Enable pushState in routes.
$locationProvider.html5Mode(true).hashPrefix('!');
$routeProvider
.when('/home', {
templates: {
layout: '/views/home.html'
},
title: 'Welcome!'
})
.when('/launchpad', {
templates: {
layout: '/views/layouts/default.html',
content: '/views/partials/profile.html'
},
title: "Launchpad"
})
.otherwise({
redirectTo: '/home'
});
}
]);
For people who are still facing this error, with or without SSL:
Make sure you Allowoverride in your apacheconfig e.g.
<Directory "/var/www/mysite/public_html">
AllowOverride All
</Directory>
for both ports is u use SSL