0

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 
Michelangelo
  • 5,888
  • 5
  • 31
  • 50
  • Hey my friend did you got it to work? I have the same issue I did all twiks I found but my pages still getting the 404 error after i refresh any page on the application – Cesar Vega Jul 15 '15 at 13:47
  • @Xvegas Nope, never got it to work with IIS. I called my hosting provider and asked them if they could help me out. They were aware of the problem and the only thing they could do is move my website to a different server that ran on Apache and it solved all my problems. – Michelangelo Jul 15 '15 at 22:44
  • OK I solve it in IIS here is a link where I post the answer [SAMPLE](http://stackoverflow.com/questions/28678950/angularjs-routing-not-working-after-site-hosted-into-iis/31437729#31437729) – Cesar Vega Jul 17 '15 at 20:25

0 Answers0