I have been through all posts on the forum on URL rewriting for AngularJS routing. I want to get rid of the hash in my URL and I can, but on refresh I still get a 404 Error. My hostingprovider has IIS installed and they have some documentation on how to write rules in a iirf.ini
file. Most of the time it is similar to htacces
files (although I had some headaches in the past because their documentation is outdated and very basic) and I am far from an expert with rewriting (I just copy/paste most of the time). They describe how to do it for Magento, Joomla and so on.
But now I am completely frustrated because I cannot seem to get url rewriting to work when I use AngularJS Routing and not have a 404 on refresh of page.
Has somebody ever written an iirf.ini
file for URL rewriting with AngularJS routing system? Is there maybe a different solution to rewrite URLs not depending on server side rewrite and on refresh not getting a 404 error. Man, I am seriously considering leaving this hostingprovider. Here is what I am trying to do now and it gets rid of the #
, but refreshing gives an error:
HTML
<base href="/" />
JS
.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/home.html',
})
.when('/opleidingen', {
templateUrl: 'partials/opleidingen.html'
})
.when('/vaardigheden', {
templateUrl: 'partials/vaardigheden.html'
})
.when('/over', {
templateUrl: 'partials/over.html'
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}
iirf.ini
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.html/#/$1