Still getting 'Not Found' when manually refreshing with angular.js route
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 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' }); }]);
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