I have an angularJS application which requires logging in. I have defined my states in the application. If I don't log in and directly open a state in the browser it redirects to 404.

The issue is when I explicitly open a .html page in browser without logging in, it shows me the HTML elements and non-rendered angularJS expressions. In the network tab of developer tools, the Status Code is 200. How do I get 404 instead and the same to redirect to 404 or login page?

My application is hosted on Apache Tomcat. 

Any help is appreciated.

**Update:**

The following is an example: (I can't provide code though).

Let's say I have a folder client with ClientView.html as the view in the folder. The following would be the route in my app.js

```
.config(function ($stateProvider, $httpProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
    .state('app.client', {
    // child state of `app`                       
    url: '/client',
    views: {
        'content@app': {
            templateUrl: 'client/ClientView.html',
            controller: 'ClientCtrl'
        },
        data: {
            requireLogin: true
        }
    }
})

```

});

If I access the application as <http://localhost/app/client> without logging in, this does take me to 404. 

But if I try to access <http://localhost/app/client/ClientView.html> then it shows me the html elements in that page as well as non-rendered AngularJs expressions. How do I redirect to login page or 404?