Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.
This repository was archived by the owner on Mar 26, 2018. It is now read-only.

AngularJS routes gives an 404 error on page refresh! #1390

@khian29

Description

@khian29

Hi everyone! I am new to AngularJS and I love coding with it, but I got some issue regarding on angular routes when it is being refresh, it gives me an 404 error. I am using apache! Heres my code: \

 var app = angular.module("CVSRRC", ['ngMaterial','ngRoute']);

  app.controller('CVSRRC-CTRL', function($scope, $http, ...){
    // some codes here...
});

app.config(function($routeProvider, $locationProvider){
$locationProvider.html5Mode(true).hashPrefix('!');

$routeProvider
.when('/', {
    templateUrl: '_pages/home',
    controller: 'homeCTRL',
    resolve: {
       delay: function($q, $timeout){
            var delay = $q.defer();
            $timeout(delay.resolve, 1000);
            return delay.promise;
       }
    }  
})
   //etc
.otherwise({
     redirectTo: '/'
    });
});

And my PHP FILE

   <html>
   <head>
   <base href="/cvsrrc/" />
   </head>
   <body ng-app="CVSRRC" ng-controller="CVSRRC-CTRL">

    <div class="row" id="main">
       <div ng-view ng-show="statechange"></div>
        <div ng-show="!statechange" cvsrrc-resolve>
             <div id="_loader_"></div>
        </div>
    </div>

        <a href="about-us">About</a>
        <a href="login">login</a>

    </body>
</html>

Here's my .htaccess look like:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
ErrorDocument 404 http://localhost/cvsrrc/page-not-found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions