Still Getting 'not Found' When Manually Refreshing With Angular.js Route
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: browse to localhost --
Solution 1:
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>
Solution 2:
I don't know if this is the optimal solution, but I did find a combination of settings that worked:
- Include the
hashPrefix('!')
(see below) - Did not include
<base href="/">
in my index.html - Added
FallbackResource /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 localmod_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'
});
}
]);
Solution 3:
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
Solution 4:
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
Post a Comment for "Still Getting 'not Found' When Manually Refreshing With Angular.js Route"