Page not found while reload page during # removal

I have made changes in my index.html and app.js.

This is app.js file.

angular
        .module('assessmentApp', ['ngRoute', 'ngCookies', 'ngSanitize', 'timer', 'assets', 'youtube-embed'])
        .config(config)
        .run(run);

    config.$inject = ['$routeProvider', '$locationProvider', '$httpProvider'];

    function config($routeProvider, $locationProvider, $httpProvider) {
        /*$locationProvider.html5Mode({
          enabled: true,
          requireBase: false
        });*/
        $routeProvider
            .when('/', {
                templateUrl: 'views/home.html',
                controller: 'HomeController',
                controllerAs: 'vm'
            })
            .when('/login', {
                templateUrl: 'views/login.html',
                controller: 'LoginController',
                controllerAs: 'vm'
            })
        if(window.history && window.history.pushState){
                $locationProvider.html5Mode({
                    enabled: true,
                    requireBase: true,
                    rewriteLinks: true
                });
            }
    }

This is Index.html.

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Assessment</title>
    <meta name="description" content="">
    <meta http-equiv=X-UA-Compatible content="IE=edge">
    <meta name=viewport content="width=device-width,initial-scale=1">
    <base href="/assessment/"></base>
</head>
</html>
  • I have followed all the solution which is present related to my problem but still my app not working.
  • I am using nginx server but I don't know is any changes requied or not? If yes then what change?
  • I added html5 api and base tag and i removed all # from my app html file so my app is working fine but when I am going to reload my application it return page not found

  • Make sure your server is set so that it is returning your index.html instead of a 404. In your nginx config for this site add:

    error_page 404 =200 /index.html;
    

    Alternatively, you can redirect like this:

    try_files $uri $uri/ /index.html;
    
    链接地址: http://www.djcxy.com/p/77694.html

    上一篇: 这是一个AngularJS服务伪装成工厂吗?

    下一篇: 在#移除期间重新加载页面时找不到页面