skip to Main Content

On my website, if I load a template and then refresh that page, I get a “page not found” error. Is there any way to prevent this?

I can post the code, but I’m not quite sure which piece of code would be valuable. Here is my home page (where the templates are pulled in):

<!DOCTYPE html>
<html data-ng-app="MainApp">
    <head >
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="shortcut icon" type="image/x-icon" href="img/computer.ico" />
        <title>Erica Peharda</title>
        <!--angular uses this base element which path to use when it gets any front end resource- this is the root b/c of "/"-->
        <base href='/'>

        <div class='container1'>
            <div class='page-header'>
            <nav class="navbar navbar-default">
                <div class="container">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="/">Welcome to EP Web Developing!</a>

                    <!--default menu bar below-->
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="/"><i class="fa fa-home"></i>Home</a></li>
                        <li><a href="/about"><i class="fa fa-shield"></i>About Me</a></li>
                        <li><a href="/contact"><i class="fa fa-comment"></i>Contact for a Quote</a></li>
                        <li><a href="/projects"><i class="fa fa-comment"></i>Projects</a></li>

                <h1 class="titleText pull-left">Erica Peharda</h1>
                <!--got code below from>
                <div class="countdownContainer pull-right">
                        <div align="center" class="noCountdown">
                    <script type="text/javascript" src=" is on 31st October 2015&group=Holiday&calendar=International&widget_number=3">
                <div class="photobanner">
                    <img class="first" src="img/pic1.jpg"/>
                    <img src="img/pic2.jpg"/>
                    <img src="img/pic3.jpg"/>
                    <img src="img/pic4.jpg"/>
                    <img src="img/pic1.jpg"/>
                    <img src="img/pic2.jpg"/>
                    <img src="img/pic3.jpg"/>
                <div class="row">
                    <div class="col-md-4">
                        <a href=""><img class="twitter" src="img/twitter.png"/></a> <a href=""><img class="twitter" src="img/facebook.png"/></a>


                    <!--the place holder to render our view dependent on the route-->
            <div class="row">
                <div class="col-sm-12" ng-view>


        <script type='text/javascript' src="lib/jquery/dist/jquery.min.js"></script>
                <link rel="stylesheet" type="text/css" href="lib/bootstrap/dist/css/bootstrap.min.css">
        <script type="text/javascript" src="lib/bootstrap/dist/js/bootstrap.min.js"></script>

        <script type="text/javascript" src="lib/angular/angular.min.js"></script>
        <script type="text/javascript" src="lib/angular-route/angular-route.min.js"></script>
        <script type="text/javascript" src="lib/angular-resource/angular-resource.min.js"></script>
        <script type="text/javascript" src="src/app.js"></script>
        <script type="text/javascript" src="src/controller.js"></script>
        <script type="text/javascript" src="src/factories.js"></script>
        <script type="text/javascript" src="src/filter.js"></script>
        <script type="text/javascript" src="src/style.js"></script>
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <link href='' rel='stylesheet' type='text/css'>


Thanks in advance!!

Here is my router config:
angular.module(‘MainApp’,[‘ngRoute’, ‘ngResource’])

.config(function($routeProvider, $locationProvider){
            contorller: 'HomeController'
        .when('/about', {
            templateUrl: 'views/about.html',
            controller: 'AboutController'
            templateUrl: 'views/contact.html',
            controller: 'EmailController'
            templateUrl: 'views/projects.html',
            controller: 'ProjectController'
        .otherwise({ redirectTo: '/' });
        //this is incase we need to add the #!



  1. Chosen as BEST ANSWER

    After I finally narrowed down what I needed to search for, I found this solution:

    Still getting 'Not Found' when manually refreshing with angular.js route

    It has to do with enabling HTML5 mode. You need to edit the .htaccess file with the following code in order to get the page refresh to re-route to your index.html file:

    <IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteBase / 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_URI} !^/$ 
    RewriteRule ^.*$ index.html

    It was the last response on the page (not sure why it didn't get more upvotes- it was the only thing that worked after an exhaustive search).

    Thank you everyone!

  2. Can you provide your router configuration ? It may happen from html5 mode .If you have configured it.

    Login or Signup to reply.
  3. I would also add that this is probably server side. Try to open the javascript console in Chrome and go to the Network tab. (or in any browser for that matter). Look at each line and find the red line that’s returning a 404 error. Look at the request url and from there you’ll be able to solve the problem if a) that request url is wrong or b) nothing exists at that url.

    Here’s some info on the debugging within the network tab in Chrome. I recommend as it will solve you a lot of time later!

    Login or Signup to reply.
  4. You need to configure your server to return /index.html for all text/html 404 errors. Another way to go about this is to copy /index.html as 404.html (or whatever your 404 document is).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top